473,480 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

where can i found my declaration syntax error?

Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. void main()
  3. {
  4. char choice;
  5. int month,sum,num,i,a,b;
  6. int age,kasarian;
  7. char ans;
  8. int e,c,d;
  9. int num1,num2,diff,prod;
  10. clrscr();
  11.  
  12.        main_menu:
  13.        {
  14.        printf("          ++++++MAIN_MENU+++++\n");
  15.        printf("          +  [1]   if        +\n");
  16.        printf("          +  [2]   switch    +\n");
  17.        printf("          +  [3]   for loop  +\n");
  18.        printf("          +  [4]   exit      +\n");
  19.        printf("          ++++++++++++++++++++\n");
  20.        printf("enter your choice:");
  21.        scanf("%d",&choice);
  22.        clrscr();
  23.      if(choice=='1')
  24.        {
  25.        if_program:
  26.        printf("        *#*#*#*#*#*#*#*#*#*#*#*#*\n");
  27.        printf("        *       [A] age         *\n");
  28.        printf("        *       [b] mdas        *\n");
  29.        printf("        *#*#*#*#*#*#*#*#*#*#*#*#*\n");
  30.        printf("Enter Your choice:");
  31.        scanf("%s",&choice);
  32.  
  33.      if((choice=='A')||(choice=='a'))
  34.     {
  35.      printf("enter your age:\n");}
  36.      scanf("%d",&age);
  37.     if(age>=0 && age<=2)
  38.      {printf("still a baby",age);}
  39.     else if(age>=3 && age<=12)
  40.     { printf("children",age);}
  41.     else if(age>=13 && age<=17)
  42.     { printf("teenager",age);}
  43.     else if(age>=18 && age<=26)
  44.      {printf("young adult",age);}
  45.     else if(age>=27 && age<=39)
  46.     { printf("middle age",age); }
  47.     else if(age>=40 && age<=79)
  48.      {printf("grand parents",age);}
  49.     else
  50.      {printf("higher",age);}
  51.  
  52.  
  53.      printf("do u want to run another if_program?'Y'/'N'");
  54.      scanf("%s",&ans);
  55.      if((ans=='Y')||(ans=='y'))
  56.  
  57.      {goto if_program;}
  58.  
  59.       }
  60.       }
  61.      if(choice=='B')
  62.      {
  63.      printf("   !!!!!!!!!!!!!!!!!!!!!!!!\n");
  64.      printf("   !! [1] addition       !!\n");
  65.      printf("   !! [2] subtraction    !!\n");
  66.      printf("   !! [3] multiplication !!\n");
  67.      printf("   !!!!!!!!!!!!!!!!!!!!!!!!\n");
  68.      printf("enter your choice:");
  69.      scanf("%d",&choice);
  70.         if(choice==1)
  71.       {
  72.        printf("addition");
  73.        printf("enter the first number:");
  74.        scanf("%d",&num1);
  75.        printf("enter the second number:");
  76.        scanf("%d",&num2);
  77.  
  78.        sum = num1 + num2;
  79.        printf("The sum of two numbers is:%d",sum);
  80.       }
  81.      else if(choice==2)
  82.      {
  83.        printf("subtraction:");
  84.        printf("enter the first number:");
  85.        scanf("%d",&num1);
  86.        printf("enter the second number");
  87.        scanf("%d",&num2);
  88.  
  89.        diff= num1 - num2;
  90.        printf("the difference of two numbers is:%d",diff);
  91.       }
  92.       else
  93.       {
  94.         printf("multiplication");
  95.         printf("enter the first number");
  96.         scanf("%d",&num1);
  97.         printf("enter the second number");
  98.         scanf("%d",&num2);
  99.  
  100.         prod=num1 * num2;
  101.         printf("the product of two numbers is:%d",prod);
  102.       }
  103.  
  104.      printf("GO BACK TO MAIN MENU?'Y'/'N'");
  105.      scanf("i",&ans);
  106.      if((ans=='Y')||(ans=='y'))
  107.      {goto main_menu;}
  108.  
  109.       }
  110.       }
  111.       if(choice=='2')
  112.      {
  113.      switch_program:
  114.  
  115.      printf(" #####################\n");
  116.      printf(" ##  [W]  kasarian  ##\n");
  117.      printf(" ##  [Z]  animals   ##\n");
  118.      printf(" #####################\n");
  119.      printf("enter your choice");
  120.      scanf("%s",&choice);
  121.      switch(choice);
  122.  
  123.      if(choice=='W')
  124.  
  125.      {
  126.       printf("ienter ang iyong kasarian:");
  127.       scanf("%s",&kasarian);
  128.       switch(kasarian)
  129.       {
  130.         case 'a' : case 'A':
  131.       {
  132.        printf("ikaw ay BABAE");
  133.        break;}
  134.         case 'b' : case 'B':
  135.        {
  136.         printf("ikaw ay LALAKI");
  137.         break;}
  138.          case 'c': case 'C':
  139.        {
  140.         printf("sa kang BAKLA");
  141.         break;}
  142.           case 'd': case 'D':
  143.        {
  144.         printf("TOMBOY ka pre");
  145.         break;}
  146.         default:
  147.  
  148.       {
  149.       printf("invalid:");
  150.  
  151.       printf("do yOU want to run another switch program:?'Y'/'N'");
  152.       scanf("%s",&ans);
  153.       if((ans=='Y')||(ans=='y'))
  154.       {goto switch_program;}
  155.      }
  156.     }
  157.      else if(choice=='Z')
  158.      {
  159.       printf("          $$$$$$$$$$$$$$$$$$$$\n");
  160.       printf("          $$    [1] dog     $$\n");
  161.       printf("          $$    [2] cat     $$\n");
  162.       printf("          $$    [3] mouse   $$\n");
  163.       printf("          $$$$$$$$$$$$$$$$$$$$\n");
  164.       scanf("%s",&choice);
  165.       switch(choice);
  166.       {
  167.        case 1:
  168.  
  169.        {printf("the dog is the biggest");
  170.          break;}
  171.        case 2:
  172.        {printf("the cat is the medium");
  173.          break;}
  174.        case 3:
  175.        {printf("the mouse is the smallest");
  176.  
  177.        printf("do you want to run another program?'Y'/'N'");
  178.        scanf("s",ans);
  179.        if((ans=='Y') || (ans=='y'))
  180.        {goto main_menu;}
  181.      }
  182.      }
  183.        }
  184.        }
  185.       if(choice=='3')
  186.       { loop_program:
  187.        printf("  ::::::::::::::::::::\n");
  188.        printf("  :::  [E] sum     :::\n");
  189.        printf("  :::  [F]         :::\n");
  190.        printf("  ::::::::::::::::::::\n");
  191.        printf("enter your choice");
  192.        scanf("s",&choice);
  193.        if (choice=='E')
  194.        {
  195.         for(e=1;e<=1;e++)
  196.         {printf("$");
  197.         printf("\n");
  198.         for(c=1;c<=2;c++)
  199.         printf("$");
  200.         printf("\n");
  201.         for(d=1;d<=3;d++);
  202.         }
  203.  
  204.     }
  205.        else
  206.        {printf("invalid choice");}
  207.  
  208.    }
  209. getch();
  210. }
Oct 18 '10 #1
2 1277
Meetee
931 Recognized Expert Moderator Contributor
Can you please post the error message also? I think, it would be always helpful to describe a problem.
Oct 18 '10 #2
newb16
687 Contributor
Closing brace on line 110 corresponds to open brace at line 3 - the body of main() function, so it refuses to parse 'if' operator outside the function body. It's not surprising you messed up the braces given that this code is a unstructured mess of ifs and elses.
Oct 18 '10 #3

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

Similar topics

2
5308
by: DouggieC | last post by:
Hi, I am attempting to overload the '<' operator in order to sort an array structure, but get a syntax error in Borland Builder5. Code as follows: struct GroupTeamType { AnsiString Name;...
3
17398
by: mandogon | last post by:
Hello peoples i am having trouble compiling this program getting a the error is "Declaration Syntax error" using borland c++ bulider v.6 if any one can help thanks void __fastcall...
2
3962
by: kellymart87 | last post by:
//remain.cpp #include <iostream.h> #include <conio.h> int main() getline ()
5
1830
DanielTNBaker
by: DanielTNBaker | last post by:
Basically gettting a "Declaration Syntax Error" do not understand what i have done wrong would appreciate it if someone could help. void Search_Client(void); void PriceList(void); void...
2
4697
by: Lothsfeld | last post by:
Can someone help me w/ this I can't run it and I keep getting errors unable to open include file 'stdio.h' and declaration syntax error #include<stdio.h> main(); { int a,b,c; ...
7
4613
by: Bowzer1999 | last post by:
I am a beginner at C++ and would be very grateful if someone could simply tell me why my program will not compile. My program is as follows, #include <stdio.h> #define int 1ST VALUE = 23.0 ...
4
4173
by: networkmancer | last post by:
Written in Turbo C++ so dont tell me its very messy because I know it is and this is an assignment that we must stick in to. The source of the problem is in Case 5 int main { . I just dont know how...
11
3304
by: Blondie1966 | last post by:
Im trying to write a program about a truck inventory with trucks coming and going and the amount in each one, but keep coming up with declaration syntax error.. Any help would be greatly appreciated....
3
1782
by: dianaroslan | last post by:
There are three errors in coding during compile. one of them is the declaration syntax error. can help me to finish coding this? really need help from anyone who knows. i have some problem with my...
0
6911
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7091
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
6966
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5344
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4787
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4488
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2999
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
564
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.