473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Declaration Syntax Error on line 155?

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 to fix it.

Expand|Select|Wrap|Line Numbers
  1.  
  2. #include <stdio.h>
  3. #include <conio.h>
  4. #include<process.h>
  5. #include<dos.h>
  6. void graph();
  7. void foo(){
  8. int a,b;
  9. clrscr();
  10.  
  11. gotoxy(27,12);textcolor(12);cprintf(" ");
  12. gotoxy(40,14);textcolor(12);cprintf(" ");
  13. gotoxy(29,16);textcolor(12);cprintf("  ");
  14. for(a=1;a<=72;a++){
  15. gotoxy(5+a,2);printf("Í");
  16. gotoxy(5+a,23);printf("Í");
  17. }
  18. for(b=1;b<=20;b++){
  19. gotoxy(5,2+b);printf("º");
  20. gotoxy(78,2+b);printf("º");
  21. }
  22. for(int s=1; s<=3;s++){
  23. gotoxy(41,2+s);printf("º"); }
  24. for(int o=1;o<=72;o++){
  25. gotoxy(5+o,5);printf("Í");
  26. }
  27. gotoxy(5,2);printf("É");
  28. gotoxy(78,2);printf("»");
  29. gotoxy(5,23);printf("È");
  30. gotoxy(78,23);printf("¼");
  31. gotoxy(41,2);printf("Ë");
  32. gotoxy(5,5);printf("Ì");
  33. gotoxy(78,5);printf("¹");
  34. gotoxy(41,5);printf("Ê");
  35.  
  36.  
  37. getche();
  38.  
  39.  
  40. getche();
  41.  
  42. graph();
  43. }
  44. void graph()
  45. {
  46. clrscr();
  47. int choice;
  48. char z,m;
  49.  
  50.  gotoxy (12,12);textcolor(4+BLINK); cprintf("LOADING:");
  51.  for(m=1;m<=50;m++){
  52.  gotoxy(19+m,12);textcolor(RED);cprintf("²");
  53.  }for (z=1;z<=50;z++){
  54.  gotoxy(19+z,12);textcolor(GREEN);cprintf("Û");
  55.  delay(40);
  56.  }clrscr();
  57. gotoxy(27,3);textcolor(12);cprintf(" ");
  58. gotoxy(40,4);textcolor(12);cprintf(" ");
  59. gotoxy(29,5);textcolor(12);cprintf(" ");
  60.  
  61. for(int g=1;g<=72;g++){
  62. gotoxy(5+g,2);printf("Í");
  63. gotoxy(5+g,23);printf("Í");
  64. }
  65. for(int v=1;v<=20;v++){
  66. gotoxy(5,2+v);printf("ߺ");
  67. gotoxy(78,2+v);printf("ºß");
  68. }
  69. for(int k=1; k<=3;k++){
  70. gotoxy(41,2+k);printf(""); }
  71. for(int p=1;p<=72;p++){
  72. gotoxy(5+p,6);printf("Í");
  73. }
  74. gotoxy(5,2);textcolor(GREEN);cprintf(" É");
  75. gotoxy(78,2);textcolor(GREEN);cprintf("» ");
  76. gotoxy(5,23);textcolor(GREEN);cprintf("ßÈ");
  77. gotoxy(78,23);textcolor(GREEN);cprintf("¼ß");
  78. gotoxy(41,2);textcolor(GREEN);cprintf("Í");
  79. gotoxy(5,6);textcolor(GREEN);cprintf("ßÌ");
  80. gotoxy(78,6);textcolor(GREEN);cprintf("¹ß");
  81. gotoxy(41,6);textcolor(GREEN);cprintf("Í");
  82. for(int l=1;l<=50;l++){
  83. gotoxy(17+l,7);textcolor(YELLOW);cprintf("ß");
  84. gotoxy(17+l,20);textcolor(YELLOW);cprintf("Ü");
  85. }
  86. for(int n=1;n<=14;n++)
  87. {
  88. gotoxy(18,6+n);textcolor(YELLOW);cprintf("Þ");
  89. gotoxy(67,6+n);textcolor(YELLOW);cprintf("Ý");
  90. }
  91. gotoxy(37,7);textcolor(9);cprintf("  M E N U  ");
  92. gotoxy(30,9);textcolor(6);cprintf("[1] EVEN/ODD IDENTIFIER");
  93. gotoxy(30,11);textcolor(6);cprintf("[2] 1000x NAME MULTIPLIER");
  94. gotoxy(30,13);textcolor(6);cprintf("[3] MULTIPLICATION TABLE");
  95. gotoxy(30,15);textcolor(6);cprintf("[4] TRIANGLE AREA CALCULATOR");
  96. gotoxy(30,17);textcolor(6);cprintf("[5] P A Y R O L L");
  97. gotoxy(29,19);textcolor(6);cprintf(" [6] E X I T ");
  98. gotoxy(24,22);textcolor(4);cprintf("ENTER CHOICE:");
  99. scanf("%d",&choice);
  100. switch(choice)
  101. {
  102. case 1:int dog;
  103. clrscr();
  104.     printf("Enter number:");
  105.     scanf("%d",&dog);
  106.     if(dog%2==0)
  107.     {
  108.     printf("EVEN \n");
  109.     }
  110.     else
  111.     {
  112.     printf("ODD \n");
  113.     } getche();graph();
  114.     break;
  115. case 2:
  116.  clrscr();
  117.  int e,r,t;
  118.  char name[15];
  119.  printf("Enter your name:");
  120.  scanf("%s",&name);
  121.  gotoxy (12,12);textcolor(GREEN+BLINK); cprintf("LOADING:");
  122.  for(t=1;t<=50;t++){
  123.  gotoxy(19+t,12);textcolor(RED);cprintf("²");
  124.  }for (r=1;r<=50;r++){
  125.  gotoxy(19+z,12);textcolor(BLUE);cprintf("Û");
  126.  delay(40);
  127.  }clrscr();
  128.  for(e=1; e<=1000; e++){
  129.  printf("%s \t",name);
  130.  }
  131.  getche();graph();
  132.  break;
  133. case 3:  clrscr();
  134.     for(int a1=1;a1<=9;a1++)
  135.     {
  136.     for(int a2=1;a2<=9;a2++)
  137.     {
  138.     printf("\t");
  139.     printf("%d",a1*a2);
  140.     }
  141.     printf("\n");
  142.     }
  143.     getche();graph();
  144.     break;
  145. case 4: int a,b;
  146. clrscr();
  147.     printf("Enter base and height:");
  148.     scanf("%d%d",&a,&b);
  149.     printf("Area is %d.",(a*b)/2); getche();graph();
  150.     break;
  151. case 5:
  152.  
  153. float rate,day,gp,netpay,totald,sss,med,love;int age;
  154. float basic,cola,tax;char employee[20],addr[30],sex[10],bday[8];
  155.  
  156. int main(){
  157. clrscr();
  158.  
  159. char choice;
  160. gotoxy(20,2);textcolor(4);cprintf("Payroll System");
  161. gotoxy(20,4);textcolor(5);cprintf("Select Choices:");
  162. gotoxy(18,6);textcolor(7);cprintf("[1] Add Customer Info");
  163. gotoxy(18,7);textcolor(7);cprintf("[2] Compute Payroll");
  164. gotoxy(18,8);textcolor(7);cprintf("[3] Display Information");
  165. gotoxy(18,9);textcolor(7);cprintf("[4] Exit");
  166. gotoxy(18,10);textcolor(7);cprintf("Enter Choice:");
  167. scanf("%d",&choice);
  168. switch (choice){
  169. case 1:printf("Employee Information\n\n");
  170.     printf("Enter Employee name:");
  171.     scanf("%s",&employee);
  172.     printf("Enter address:");
  173.     scanf("%s",&addr);
  174.     printf("Enter sex:");
  175.     scanf("%s",&sex);
  176.     printf("Enter age:");
  177.     scanf("%d",&age);
  178.     printf("Enter bday:");
  179.     scanf("%s",&bday);main();
  180.  
  181. case 2:printf("Payroll Input\n:");
  182.     printf("Enter rate:");
  183.     scanf("%f",&rate);
  184.     printf("Enter day:");
  185.     scanf("%f",&day);
  186.     basic=rate*day;
  187.     cola=basic*.02;
  188.     gp=basic+cola;
  189.     sss=gp*.073;
  190.     med=gp*.081;
  191.     love=gp*.092;
  192.  
  193.     if(gp>=2500){
  194.         tax=gp*.12;}else
  195.         {
  196.         printf("No tax");}
  197.  
  198.     totald=sss+med+love+tax;
  199.     netpay=gp-totald;main();
  200.  
  201. case 3:printf("Employee Information\n");
  202.     printf("Employee name is %s\n",employee);
  203.     printf("Employee address %s\n",addr);
  204.     printf("Employee gender%c\n",sex);
  205.     printf("Employee age %d\n",age);
  206.     printf("Employee bday%s\n",bday);
  207.     printf("\n");
  208.     printf("payroll Information\n");
  209.     printf("Rate per day%.2f\n",rate);
  210.     printf("Number of day%.2f\n",day);
  211.     printf("Basic%.2f\n",basic);
  212.     printf("Cola %.2f\n",cola);
  213.     printf("Grosspay%.2f\n",gp);
  214.  
  215. printf("Tax is%.2f\n",tax);
  216.     printf("Total deduction %.2f\n",totald);
  217.     printf("netpay%.2f\n",netpay);getche();main();
  218.  
  219. case 4: exit(0);
  220. default:printf("Invalid input");getche();main();
  221. }
  222. getche();graph();
  223. break;
  224.     }
  225. case 6: exit(0);break;
  226. default:printf("Invalid Entry");
  227. }
  228. getche();}
Sep 7 '09 #1
4 4170
JosAH
11,448 Expert 8TB
You can't define a function inside the body of another function; that code is a total mess, the result of copy and paste done by someone who doesn't know what s/he is doing. Fix the structure of your code and then come back.

kind regards,

Jos
Sep 7 '09 #2
donbock
2,426 Expert 2GB
@networkmancer
There is no reason code written in Turbo C++ has to be "very messy". Perhaps it is ok for you to turn in messy code, but it takes more effort for forum members to wade through 228 lines of "messy" code, making it less likely you'll get an answer. You're fortunate that JosAH gave you such a prompt reply.
Sep 8 '09 #3
as I said its our assignment so I did not code that.
Sep 8 '09 #4
JosAH
11,448 Expert 8TB
@networkmancer
But I bet you put that "int main() {" line (line #156) in the middle of another function body.

kind regards,

Jos
Sep 8 '09 #5

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

Similar topics

3
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
by: kellymart87 | last post by:
//remain.cpp #include <iostream.h> #include <conio.h> int main() getline ()
5
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
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
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 ...
3
by: Ananthu | last post by:
Hi I have created one website named OTMS using ASP.NET in a File System Format.My project location is in F: drive(F:\Project\OTMS). I have installed IIS properly and the website runs properly in...
11
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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
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,...

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.