By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,558 Members | 1,373 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,558 IT Pros & Developers. It's quick & easy.

Syntax Error Code in C

P: 13
Hi Guys, I'm getting an error msg of 'declaration syntax error' NEED HELP!!!
Expand|Select|Wrap|Line Numbers
  1.  
  2. #include<stdio.h>
  3. #include<ctype.h>
  4.  
  5. void PrintMenu()
  6. {
  7.     printf("a) My Name \n");
  8.     printf("b) Tutorial day and time \n");
  9.     printf("c) Enter Number \n");
  10.     printf("q) Quit \n");
  11.  
  12.     return;
  13. }
  14.  
  15. char GetOption
  16. {
  17.     char option;
  18.  
  19.         scanf("%c%*c", &option);
  20.         option = tolower(option);
  21.  
  22.     return(option);
  23. }
  24.  
  25. void Printname()
  26. {
  27.     printf("Name \n");
  28.  
  29.     return;
  30. }
  31.  
  32. void PrintTut()
  33. {
  34.     printf("Tuesday 2.30pm \n");
  35.  
  36.     return;
  37. }
  38.  
  39. void PrintNumber()
  40. {
  41.     printf("Enter Number:  \n");
  42.     scanf("%d%*c", &num);
  43.     if 
  44.         (num>=1 & num<=50)
  45.         for(i=0; i>=50; i++)
  46.         printf("%d ", i);
  47.     else
  48.         printf("Error! \n");
  49.  
  50.     return;
  51. }
  52.  
  53. void DoOption(char option)
  54. {
  55.     switch(option)
  56.     {
  57.         case 'a':
  58.             PrintName();
  59.             break;
  60.         case 'b':
  61.             PrintTut();
  62.             break;
  63.         case 'c':
  64.             PrintNumber()
  65.         case 'q':
  66.             break;
  67.         default:
  68.             printf("Please enter a valid option \n");
  69.     }
  70. }    
  71.  
  72. int main()
  73.  
  74. {
  75.     int num, i;
  76.     char option;
  77.     do
  78.     {
  79.         PrintMenu();
  80.         GetOption();
  81.         DoOption();
  82.  
  83.     }while(option!='q');
  84.  
  85.     return(0);
  86. }
  87.  
Thanks
Sep 7 '10 #1
Share this Question
Share on Google+
5 Replies


ashitpro
Expert 100+
P: 542
1: "char GetOption" should be "char GetOption()" i.e missing brackets

2: in PrintNumber() function, "num" and "i" is undeclare

3: in DoOption method, semicolon is missing after case 'c' i.e. for PrintNumber() statement

4: In main, DoOption() is called without any parameter, it expect single parameter
Sep 7 '10 #2

ashitpro
Expert 100+
P: 542
1: "char GetOption" should be "char GetOption()" i.e missing brackets

2: in PrintNumber() function, "num" and "i" is undeclare

3: in DoOption method, semicolon is missing after case 'c' i.e. for PrintNumber() statement

4: In main, DoOption() is called without any parameter, it expect single parameter
Sep 7 '10 #3

P: 13
Thanks so much!!!
Sep 7 '10 #4

Oralloy
Expert 100+
P: 983
@deenar,

We have no problem helping at all.

Next time, though, will you be kind enough to provide the exact error messages - it helps a lot when working these sorts of problems.

Also, and I'm being "subtle" here - read the error messages and try to figure out what they mean. Most compilers tell you line number and some kind of indicator of what happened. It'll sure save you a lot of time, next time you need to get some code working.

Cheers!
Oralloy
Sep 7 '10 #5

P: 13
Sorry i'm new to all this but def if i need help i'll put the error msgs as well. I had looked at the error on the line and it said i was missing a syntax error on line 22 which was just 'return;'. Thanks anyway...
Sep 10 '10 #6

Post your reply

Sign in to post your reply or Sign up for a free account.