scanf("%c",reply);
should be
scanf("%c",&reply);
Jim Dougherty <[EMAIL PROTECTED]> 写道:
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
> 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
> 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 .
Yahoo! Groups Links
---------------------------------
抢注雅虎免费邮箱3.5G容量,20M附件!
[Non-text portions of this message have been removed]