Expression syntax error in function main | Newbie | | Join Date: Feb 2007
Posts: 4
| | |
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!..
|  | Site Moderator | | Join Date: Jan 2007 Location: America
Posts: 3,387
| | | 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.
| | Newbie | | Join Date: Apr 2009
Posts: 1
| | | re: Expression syntax error in function main -
#include<stdio.h>
-
#include<string.h>
-
#define p printf
-
#define s scanf
-
#define g gotoxy
-
-
main()
-
{
-
int ctr,count;
-
char log[10],pass[10];
-
char ans, wrd[30], letter='a';
-
float Q1,Q2,Q3,gen_ave,mid,aten,agg,fQ1,fQ2,fQ3,fgen_ave,fa,fmid,faten,fagg,b,a,f;
-
int c,choice;
-
int gc,a1,a2,equal;
-
-
-
Q1=0;
-
Q2=0;
-
Q3=0;
-
mid=0;
-
aten=0;
-
fQ1=0;
-
fQ2=0;
-
fQ3=0;
-
fmid=0;
-
faten=0;
-
-
clrscr();
-
p("Username: ");
-
g(1,2);
-
p("Enter your password: ");
-
-
g(11,1);
-
s("%s",log);
-
c=strcmp(log,"mariano");
-
-
g(22,2);
-
s("%s",pass);
-
c=strcmp(pass,"lenonmariano");
-
-
-
if(c==0)
-
{
-
clrscr();
-
g(30,2);
-
p("Main Menu");
-
g(30,5);
-
p("1. Computation");
-
g(30,6);
-
p("2. Grade Computation");
-
g(30,7);
-
p("3. String Manipulation");
-
g(30,8);
-
p("4. Vowel");
-
g(30,9);
-
p("5. Exit");
-
g(30,11);
-
p("Choose [1-5]: ");
-
s("%d",&choice);
-
}
-
else
-
p("Wrong Username or Password");
-
-
if(choice==1)
-
{
-
clrscr();
-
g(35,2); p("Main Menu");
-
g(33,5); p("1. ADDITION");
-
g(33,6); p("2. SUBTRACT");
-
g(33,7); p("3. MULTIPLY");
-
g(33,8); p("4. DIVIDE");
-
g(33,9); p("5. QUIT");
-
g(28,11); p("Choose Computation [1-5]: ");
-
s("%d",&gc);
-
}
-
else if(choice==2)
-
{
-
clrscr();
-
g(5,3); p("Q1");
-
g(10,3); p("Q2");
-
g(15,3); p("Q3");
-
g(20,3); p("Midterm");
-
g(30,3); p("Attendance");
-
g(45,3); p("Over All Grade");
-
-
g(5,4); s("%f",&Q1);
-
g(10,4); s("%f",&Q2);
-
g(15,4); s("%f",&Q3);
-
-
gen_ave=(Q1+Q2+Q3)/3;
-
-
g(20,4); s("%f",&mid);
-
g(30,4); s("%f",&aten);
-
g(45,4); agg=(gen_ave*.3)+(mid*.6)+(aten*.1);
-
p("%.2f",agg);
-
getch();
-
-
clrscr();
-
-
g(5,3); p("Q1");
-
g(10,3); p("Q2");
-
g(15,3); p("Q3");
-
-
g(5,3); p("Q1");
-
g(10,3); p("Q2");
-
g(15,3); p("Q3");
-
g(20,3); p("Final Term");
-
g(30,3); p("Attendance");
-
g(45,3); p("Over All Grade");
-
-
g(5,4); s("%f",&fQ1);
-
g(10,4); s("%f",&fQ2);
-
g(15,4); s("%f",&fQ3);
-
-
fgen_ave=(fQ1+fQ2+fQ3)/3;
-
-
g(20,4); s("%f",&fmid);
-
g(30,4); s("%f",&faten);
-
-
g(45,4); fagg=(fmid*.6)+(faten*.1)+(fgen_ave*.3);
-
p("%.2f",fagg);
-
-
getch();
-
clrscr();
-
-
g(5,3); p("Final Grade");
-
b=agg*.40;
-
a=fagg*.60;
-
-
g(5,4);
-
f=b+a;
-
p("%.2f",f);
-
}
-
else if(choice==3)
-
{
-
clrscr();
-
count=0;
-
g(22,8); p("Enter A String: ");
-
s("%s",&wrd);
-
g(22,9);
-
for(ctr=0; (ctr(=strlen(wrd)-1); ctr++)
-
{
-
if(wrd[ctr]==letter)
-
{
-
count=count+1;
-
}
-
}
-
p("Your letter is: ");
-
p("%i",count);
-
-
}
-
getch();
-
}
-
-
email me if you see my error! <Removed>! help me!
| | Lives Here | | Join Date: Sep 2006
Posts: 12,070
| | | 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)
| | Needs Regular Fix | | Join Date: Jul 2008
Posts: 381
| | | re: Expression syntax error in function main Quote:
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.
|  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,295 network members.
|