473,946 Members | 17,270 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Declaration Syntax Error on line 155?

2 New Member
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 4208
JosAH
11,448 Recognized Expert MVP
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 Recognized Expert Top Contributor
@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
networkmancer
2 New Member
as I said its our assignment so I did not code that.
Sep 8 '09 #4
JosAH
11,448 Recognized Expert MVP
@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
17435
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 TFrame2::FrameClick(TObject *Sender) { int main() { //it is showing the error right here ifstream myfile("c:\fileopen.txt");
2
4006
by: kellymart87 | last post by:
//remain.cpp #include <iostream.h> #include <conio.h> int main() getline ()
5
1867
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 Exit(void); client_struct fetchrec(); <-- getting error here void writerec (FILE * client_file, struct client_struct client); thanks for help =]
2
4733
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; clrscr();
7
4641
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 void main() {
3
10495
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 Internet Explorer as a File System Format. I have created a new virtual directory(OTMS) in IIS and i have included my website directory(F:\Project\OTMS) which i have designed in file system format and when i run in Opera using the address, ...
11
3351
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. Im using Borland C++. Thanks #include <iostream.h> #include <iomanip.h> #include <stdlib.h> #include <conio.h> #include <string.h> #include <ctype.h>
3
1807
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 total function and declaration. #include <iostream> #include <conio> const int listSize=1; struct employeeInfo { char name, address,noPhone;
0
10150
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9975
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11142
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11325
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10679
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9873
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4525
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3526
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.