I am having problems with my code. I thought it was right, but the compiler disagrees with me. My code is posted below along with the errors that I am receiving. Any help would be greatly appreciated and I thank you beforehand. I just dont know what I am doing wrong!
Here are the errors:Code:#include <stdio.h> int main(void) { int sum = 0; int product = 0; int curr; char letter; do { printf("CS2432 Program 3 Menu Program\n"); printf("A. Calculate the sum of a series of whole numbers.\n"); printf("B. Calculate the product of a series of whole numbers.\n"); printf("C. Exit the program\n"); printf("Please enter your choice:\n"); scanf("%c", &letter); if(char != 'a' || char != 'b' || char != 'c' || char != 'A' || char != 'B' || char != 'C') { printf("Error: Invalid input! Try Again!\n"); break; } else switch(&letter) { case 'a': case 'A': printf("Enter the integers to be summed(0 to exit):\n"); while(curr != 0) { scanf("%d", &curr); sum += curr; } /*end of while statement*/ printf("The total is %d\n", sum); return sum; break; case 'b': case 'B': printf("Enter the integers to be multiplied(1 to exit):\n"); while(curr != 1) { scanf("%d", &curr); product *= curr; } /*end of while statement*/ printf("The product is %d\n", product); return product; break; case 'c': case 'C': /*exit program*/ } /*end of switch statement*/ } /*end of do statement*/ } /*end of main statement*/
program3.c:28: error: parse error before "char"
program3.c:34: error: parse error before "else"
program3.c:49: error: case label not within a switch statement
program3.c:49: error: case label not within a switch statement
program3.c:61: error: case label not within a switch statement
program3.c:61: error: case label not within a switch statement
program3.c:64: warning: deprecated use of label at end of compound statement
program3.c:32: error: break statement not within loop or switch
program3.c:47: error: break statement not within loop or switch
program3.c:59: error: break statement not within loop or switch
program3.c: At top level:
program3.c:66: error: parse error before '}' token



LinkBack URL
About LinkBacks


