Can anyone help a rookie new to C who is working hard to figure out and get comfortable with functions?? Below is my code for a program that is to prompt user for input to draw a shape by invoking the corresponding function. Right now I cannot get it to compile. I am getting an error "C:\Documents and Settings\Owner\My Documents\project2.c(70) : error C2143: syntax error : missing ';' before 'type' " [reference line is: int circle (int shape) ].
Could someone please take a look at my code? I am still working to understand functions and even all the concepts of C. I have not been able to locate the source of the error and am also afraid even if I can that I may have used incorrect data types, called the functions incorrectly, etc. Any and all suggestions and assistance would be appreciated. Thanks,
Code:/*This program will draw a shape based on a value entered*/ /*by the user until the sentinel value is entered to terminate*/ /* the program. */ #include <stdio.h> int circle (int shape); int triangle(int shape); int rectangle (int shape); int line(int shape); int main() { int shape=0; /* Initialize variable */ printf("This program will draw a shape on your screen based on \n"); /*Prompt user for correct input*/ printf("your selection from the following menu: \n \n"); printf("1. Draw a circle. \n"); printf("2. Draw a triangle. \n"); printf("3. Draw a rectangle. \n"); printf("4. Print one blank line. \n"); printf("5. Exit program.\n \n"); printf("Enter your choice: \n"); scanf("%d", &shape); /* Read value user enters from keyboard */ fflush(stdin); while (shape != 5) { /*While loop to continue program until sentinel value is entered*/ { printf("This program will draw a shape on your screen based on \n"); /*Prompt user for correct input*/ printf("your selection from the following menu: \n \n"); /*Reprompts user for input each time loop is ran*/ printf("1. Draw a circle. \n"); printf("2. Draw a triangle. \n"); printf("3. Draw a rectangle. \n"); printf("4. Print one blank line."); printf("5. Exit program."); printf("Enter your choice: \n"); scanf("%d", &shape); /* Read value user enters from keyboard */ fflush(stdin); switch (shape) /* switch nested in while to draw shape corresponding to the integer input*/ /*by a call issued to correct function */ { case 1: printf("Circle printed below as requested: \n \n ", circle); break; case 2: printf("Triangle printed below as requested: \n \n", triangle); break; case 3: printf("Rectangle printed below as requested: \n \n", rectangle); break; case 4: printf("Blank line printed below as requested: \n \n", line); break; default: printf("Incorrect value entered, please reenter. \n \n"); break; } } printf("You have terminated the program. Thank you for using the shapes program!\n"); return 0; } int circle (int shape) { printf(" * * * \n"); printf(" * * \n"); printf(" * * \n"); printf(" * * * \n"); return shape; } int triangle (int shape) { printf(" * \n"); printf(" * * \n"); printf(" * * \n"); printf(" ******** \n"); return shape; } int square (int shape) { printf(" ******** \n"); printf(" * * \n"); printf(" * * \n"); printf(" * * \n"); printf(" ******** \n"); return shape; } int line(int shape) { printf("\n"); printf("You have printed one blank line."); return shape; }