On 5/2/07, Jim Dougherty <[EMAIL PROTECTED]> wrote:
>
> 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)------------------>if(reply=='Y' or reply=='y')
> > printf("Enter onothe pair of numbers,and continue\n");
----------------------------->main();
> else
> > if(reply==n)------------------>if(reply=='N' or reply=='n')
> > printf("Programme has been terminated\n");
> > return 0;
> > }
> > double calculation(double x, double y)
> > {
> > switch (sign) {
> > case + :---------------------->case '+': //and so on
> > 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
>
>
>
>
--
Bharat Garg
Indian School of Mines
Dhanbad
[Non-text portions of this message have been removed]