Question
I need help finding the error. the error messages i keep gettingare: shapes.c:13: warning: parameter names (without types) infunction declaration shapes.c:14: warning: parameter names (without
I need help finding the error. the error messages i keep gettingare:
shapes.c:13: warning: parameter names (without types) infunction declaration
shapes.c:14: warning: parameter names (without types) in functiondeclaration
shapes.c: In function âmainâ:
shapes.c:42: error: expected expression before â)â token
shapes.c:44: error: âblanksâ undeclared (first use in thisfunction)
shapes.c:44: error: (Each undeclared identifier is reported onlyonce
shapes.c:44: error: for each function it appears in.)
shapes.c:49: error: redeclaration of âiâ with no linkage
shapes.c:43: note: previous declaration of âiâ was here
shapes.c:50: error: âstarsâ undeclared (first use in thisfunction)
shapes.c:64:10: warning: missing terminating " character
shapes.c: In function âdisplay_greeting_messageâ:
shapes.c:64: error: missing terminating " character
shapes.c:65: error: âPRINTERiâ undeclared (first use in thisfunction)
shapes.c:65: error: stray ââ in program
shapes.c:65:30: warning: missing terminating " character
shapes.c:65: error: missing terminating " character
shapes.c:65: error: ânâ undeclared (first use in thisfunction)
shapes.c:66: error: expected â)â before âprintfâ
shapes.c:67:10: warning: missing terminating " character
shapes.c:67: error: missing terminating " character
shapes.c:68: error: stray ââ in program
shapes.c:68:10: warning: missing terminating " character
shapes.c:68: error: missing terminating " character
shapes.c:86: error: expected â;â before â}â token
heres the code.
/* Prints a shape for the code user chooses
*/
#include
void display_greeting_message();
void print_square();
void print_triangle();
void print_diamond();
void display_goodbye_message();
void print_blanks(blanks );
void print_stars(stars );
int main()
{
int code;
int l = 0;
do{
display_greeting_message();
printf("Please enteryour code now: ");
scanf("%d",&code);
if (code == 1)
{
print_square();
}
if(code == 2)
{
print_triangle();
}
if (code == 3)
{
print_diamond();
}
if (code == 0)
{
display_goodbye_messgae();
}
}
while (l==));
int i;
for (i=1; i<=blanks;++i)
{
print_blanks(blanks);
printf(" ");
}
int i;
for(i=1; i<= stars;++i)
{
print_stars(stars);
printf("*");
}
void display_greeting_message()
{
printf("*************************************************************");
printf("*************WELCOME TO THE PATTERN
PRINTERi****************** ");
printf("* Enter a code 1 to print a square pattern ofstarts t * ");
printf("* Enter a code of 2 to print a right trianglepattern of
stars* ");
printf("* Enter a code of 3 to print a diamond patternof starst*");
printf("* Enter a code of 0 to stop printingpatternstt *");
printf("* ttttt*");
printf
("************************************************************");
}
void print_square()
{
int side,i;
print("Enter the size ofthe square (integer): ");
scanf("%d",&side);
for (i=1; i<=side;++i)
{
print_stars(side);
print"");
}
}
void print_triange()
{
int base,i;
printf("Enter the baseof the triangle (integer) : ");
scanf("%d",&base);
int star = 1, space=0;
space = base/2;
if (base %2 ==0)
{
while(star<=base)
{ print_blanks(space);
print_stars(star);
printf("");
space = space-1;
if(star ==1)
star = star + 1;
else
star = star + 2;
}
}
else
{
while(star <=base)
{
print_blanks(space);
print_stars(star);
printf("");
space = space -1;
star = star +2;
}
}
}
void print_diamond()
{
int width, i;
printf("Enter the widthof the diamond (integer): ");
scanf("%d",&width);
int star = 1, space =0;
space = width/2;
if(width %2 == 0)
{
while(star <=width)
{
print_blanks(space);
print_stars(star);
print("");
space = space-1;
if(star == 1)
star = star +1;
else
star = star +2;
}
if(star == 3)
star = star - 1;
else
star = star -2;
}
else
{
while(star<=width)
{
print_blanks(space);
print_stars(star);
printf("");
space = space - 1;
star = star +2;
}
star = star -2;
}
space = 1;
if (width %2 ==0)
star = star-1;
else
star = star - 2;
while(star>=1)
{
print_blanks(space);
print_stars(star);
printf("");
space = space +1;
star = star -2;
}
}
void display_goodbye_message()
{
printf("**********************************************************");
printf("* t t GOOD BYE!!!ttt*");
printf("**********************************************************");
}
Thank You!!
Step by Step Solution
3.49 Rating (169 Votes )
There are 3 Steps involved in it
Step: 1
Here the errors are spelling mistakes and syntax err...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started