Change your case lines from: "case + :" to: "case '+': You need single quotes around '+' so that the compiler knows that the + is a character constant and not an operator.
[email protected] wrote: > Can any one tell me whats wrong with this program its giving me about ten > errors of the form > > Compiling CALCULAT.C: > Error CALCULAT.C 30: Expression syntax in function calculation(double,double) > Error CALCULAT.C 31: Case statement missing : in function > calculation(double,double) > Error CALCULAT.C 33: Expression syntax in function calculation(double,double) > > #include <stdio.h> > double a,b; > char sign,reply,Y,n; > double result; > double calculation(double x,double y); > main() > { > printf("Welcome to our calculator\n"); > printf("Pliz enter the first number\n"); > scanf("%d",&a); > printf("Pliz enter the sign\n"); > scanf("%c",&sign); > printf("Enter the second number\n"); > scanf("%d",&b); > result=calculation(a,b); > printf("%d %s $d=%d",a,sign,b,result); > printf("Do you require onother transection?enter y for yes and n for no\n"); > scanf("%c",reply); > if(reply==Y) > printf("Enter onothe pair of numbers,and continue\n"); > else > if(reply==n) > printf("Programme has been terminated\n"); > return 0; > } > double calculation(double x, double y) > { > switch (sign) { > case + : > return(x+y); > break; > case * : > return(x*y); > break; > case - : > return(x-y); > break; > case / : > return(x/y); > break; > case % : > return(x%y); > break; > default :return 0; break; > } > > } > > --------------------------------- > Ahhh...imagining that irresistible "new car" smell? > Check outnew cars at Yahoo! Autos. > > [Non-text portions of this message have been removed] > > > > > > > > > > ------------------------------------------------------------------------ > > > > Can any one tell me whats wrong with this program its giving me about ten > errors > of the form > > Compiling CALCULAT.C: > Error CALCULAT.C 30: Expression syntax in function calculation(double,double) > Error CALCULAT.C 31: Case statement missing : in function > calculation(double,double) > Error CALCULAT.C 33: Expression syntax in function calculation(double,double) > > #include <stdio.h> > double a,b; > char sign,reply,Y,n; > double result; > double calculation(double x,double y); > main() > { > printf("Welcome to our calculator\n"); > printf("Pliz enter the first number\n"); > scanf("%d",&a); > printf("Pliz enter the sign\n"); > scanf("%c",&sign); > printf("Enter the second number\n"); > scanf("%d",&b); > result=calculation(a,b); > printf("%d %s $d=%d",a,sign,b,result); > printf("Do you require onother transection?enter y for yes and n for no\n"); > scanf("%c",reply); > if(reply==Y) > printf("Enter onothe pair of numbers,and continue\n"); > else > if(reply==n) > printf("Programme has been terminated\n"); > return 0; > } > double calculation(double x, double y) > { > switch (sign) { > case + : > return(x+y); > break; > case * : > return(x*y); > break; > case - : > return(x-y); > break; > case / : > return(x/y); > break; > case % : > return(x%y); > break; > default :return 0; break; > } > > } > > --------------------------------- > Ahhh...imagining that irresistible "new car" smell? > Check outnew cars at Yahoo! Autos. > > [Non-text portions of this message have been removed] > > To unsubscribe, send a blank message to <mailto:[EMAIL PROTECTED]>. Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/c-prog/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/c-prog/join (Yahoo! ID required) <*> To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
