Connect with Expertise | Find Experts, Get Answers, Share Insights

Expression syntax error in function main

 
Join Date: Feb 2007
Posts: 4
#1: Feb 20 '07
Hi and good day to all...I am new to the C language and whenever I tried to run the program I made, it won't because it says it has an "expression syntax error in function main"..what I don't get is that I know I had it done correctly and just to make sure if I was mistaken or not in writing my programs, I even copied some exapmles of programs in my book and and even in the internet...when I tried running these programs, they do not run too and says exactly the same error I've committed..please help!..

RedSon's Avatar
E
C
 
Join Date: Jan 2007
Location: America
Posts: 3,929
#2: Feb 20 '07

re: Expression syntax error in function main


A syntax error means that that code that you have written or copied into your environment was wrong or is missing some important part. If you copy and paste your code to this forum we can help you search for syntax errors. Syntax errors are the easiest errors to correct so it should be no trouble. Be sure to use "CODE" tags around your code when you copy and paste it.
 
Join Date: Apr 2009
Posts: 1
#3: Apr 2 '09

re: Expression syntax error in function main


Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<string.h>
  3. #define p printf
  4. #define s scanf
  5. #define g gotoxy
  6.  
  7. main()
  8. {
  9.     int ctr,count;
  10.     char log[10],pass[10];
  11.     char ans, wrd[30], letter='a';
  12.     float Q1,Q2,Q3,gen_ave,mid,aten,agg,fQ1,fQ2,fQ3,fgen_ave,fa,fmid,faten,fagg,b,a,f;
  13.     int c,choice;
  14.     int gc,a1,a2,equal;
  15.  
  16.  
  17.     Q1=0;
  18.     Q2=0;
  19.     Q3=0;
  20.     mid=0;
  21.     aten=0;
  22.     fQ1=0;
  23.     fQ2=0;
  24.     fQ3=0;
  25.     fmid=0;
  26.     faten=0;
  27.  
  28.     clrscr();
  29.     p("Username: ");
  30.     g(1,2);
  31.     p("Enter your password: ");
  32.  
  33.     g(11,1);
  34.     s("%s",log);
  35.     c=strcmp(log,"mariano");
  36.  
  37.     g(22,2);
  38.     s("%s",pass);
  39.     c=strcmp(pass,"lenonmariano");
  40.  
  41.  
  42.     if(c==0)
  43.     {
  44.         clrscr();
  45.         g(30,2);
  46.         p("Main Menu");
  47.         g(30,5);
  48.         p("1. Computation");
  49.         g(30,6);
  50.         p("2. Grade Computation");
  51.         g(30,7);
  52.         p("3. String Manipulation");
  53.         g(30,8);
  54.         p("4. Vowel");
  55.         g(30,9);
  56.         p("5. Exit");
  57.         g(30,11);
  58.         p("Choose [1-5]: ");
  59.         s("%d",&choice);
  60.     }
  61.     else
  62.         p("Wrong Username or Password");
  63.  
  64.     if(choice==1)
  65.     {
  66.         clrscr();
  67.         g(35,2); p("Main Menu");
  68.         g(33,5); p("1. ADDITION");
  69.         g(33,6); p("2. SUBTRACT");
  70.         g(33,7); p("3. MULTIPLY");
  71.         g(33,8); p("4. DIVIDE");
  72.         g(33,9); p("5. QUIT");
  73.         g(28,11); p("Choose Computation [1-5]: ");
  74.         s("%d",&gc);
  75.     }
  76.     else if(choice==2)
  77.     {
  78.         clrscr();
  79.         g(5,3); p("Q1");
  80.         g(10,3); p("Q2");
  81.         g(15,3); p("Q3");
  82.         g(20,3); p("Midterm");
  83.         g(30,3); p("Attendance");
  84.         g(45,3); p("Over All Grade");
  85.  
  86.         g(5,4); s("%f",&Q1);
  87.         g(10,4); s("%f",&Q2);
  88.         g(15,4); s("%f",&Q3);
  89.  
  90.         gen_ave=(Q1+Q2+Q3)/3;
  91.  
  92.         g(20,4); s("%f",&mid);
  93.         g(30,4); s("%f",&aten);
  94.         g(45,4); agg=(gen_ave*.3)+(mid*.6)+(aten*.1);
  95.         p("%.2f",agg);
  96.         getch();
  97.  
  98.         clrscr();
  99.  
  100.         g(5,3); p("Q1");
  101.         g(10,3); p("Q2");
  102.         g(15,3); p("Q3");
  103.  
  104.         g(5,3); p("Q1");
  105.         g(10,3); p("Q2");
  106.         g(15,3); p("Q3");
  107.         g(20,3); p("Final Term");
  108.         g(30,3); p("Attendance");
  109.         g(45,3); p("Over All Grade");
  110.  
  111.         g(5,4); s("%f",&fQ1);
  112.         g(10,4); s("%f",&fQ2);
  113.         g(15,4); s("%f",&fQ3);
  114.  
  115.         fgen_ave=(fQ1+fQ2+fQ3)/3;
  116.  
  117.         g(20,4); s("%f",&fmid);
  118.         g(30,4); s("%f",&faten);
  119.  
  120.         g(45,4); fagg=(fmid*.6)+(faten*.1)+(fgen_ave*.3);
  121.         p("%.2f",fagg);
  122.  
  123.         getch();
  124.         clrscr();
  125.  
  126.         g(5,3); p("Final Grade");
  127.         b=agg*.40;
  128.         a=fagg*.60;
  129.  
  130.         g(5,4);
  131.         f=b+a;
  132.         p("%.2f",f);
  133.     }
  134.     else if(choice==3)
  135.     {
  136.         clrscr();
  137.         count=0;
  138.             g(22,8); p("Enter A String: ");
  139.             s("%s",&wrd);
  140.             g(22,9);
  141.                 for(ctr=0; (ctr(=strlen(wrd)-1); ctr++)
  142.                 {
  143.                     if(wrd[ctr]==letter)
  144.                     {
  145.                         count=count+1;
  146.                     }
  147.                 }
  148.         p("Your letter is: ");
  149.         p("%i",count);
  150.  
  151.     }
  152.     getch();
  153. }
  154.  
  155.  
email me if you see my error! <Removed>! help me!
C
 
Join Date: Sep 2006
Posts: 12,070
#4: Apr 2 '09

re: Expression syntax error in function main


1.) You did not use the code tags suggested above.
2.) main must return an int. Read Ten Common Silly Mistakes
3.) Where did you declare clrscr which you are calling often? Perhaps you forgot to include conio.h (which is not available on all platforms and so should be avoided)
C
 
Join Date: Jul 2008
Posts: 586
#5: Apr 2 '09

re: Expression syntax error in function main


email me if you see my error
You confused angle bracket and parenthesis in the line pointed by compiler. Btw, you could have posted its number here so that I didn't copypaste your code and compile it for you.
Reply