+ 2
What mistake is done in this code?
#include <stdio.h> int main() { int a,b,c; scanf("%i",&a); scanf("%i",&b); printf("your answer="); scanf("%d",&c); if("c==+") printf("%d",a+b); else if("c==-") printf("%d",a-b); else if("c==*") printf("%d",a*b); else if("c==/") printf("%d",a/b); return 0; }
3 odpowiedzi
+ 4
SoloProg also making char as c
+ 3
Your condition are not correct in if statement you have to give condition you have written strings in double quotes remove them and take third input as a char type
+ 3
#include <stdio.h>
int main() {
int a,b;
char c;
scanf("%i",&a);
scanf("%i",&b);
printf("your answer=");
scanf("%c",&c);
if("c=='+'")
printf("%d",a+b);
else
if("c=='-'")
printf("%d",a-b);
else
if("c=='*'")
printf("%d",a*b);
else
if("c=='/'")
printf("%d",a/b);
return 0;
}
/* make c as char
and make operator in ''*/