+ 1
code analysis (errors?)
#include <stdio.h> int main(void) { int a,b,s; char o; printf("Primeiro numero: "); scanf("%d",&a); printf("Operador:"); scanf("%c",&o); printf("Segundo numero: "); scanf("%d",&b); if (o=='+') { s = a + b; printf("O resultado é: %d\n",s); } else if (o=='-') { s = a - b; printf("O resultado é: %d\n",s); } else if (o=='/') { s = a / b; printf("O resultado é: %d\n",s); } else if (o=='*') { s = a * b; printf("O resultado é: %d\n",s); } else { printf ("Erro!!!!!!!!"); } return 0; }
7 Antworten
+ 3
It happens,no worries .. Akib Reza
+ 2
Code is working for me .
Just neither change line nor give any space between the inputs .
Give it like 7*4 not like 7 * 4 .
+ 2
Akib Reza Double quotes will throw errors .Try compiling ur solution .
+ 1
Yah, got it. Thanks ishan i forgot.(Haven't coded cpp in a while)
0
the error is with the compiler, because when giving enter to send the input data he interpreted the enter as the "operador", just put a scanf before the scanf of the "operador", but thanks for the tips
0
😂😂 Ok. Have fun.
0
Is that at school they use compilers online :( Thanks for the attention people.