code analysis (errors?) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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; }

15th Jun 2018, 1:37 AM
Gabriel Cardoso
Gabriel Cardoso - avatar
7 Answers
+ 3
It happens,no worries .. Akib Reza
15th Jun 2018, 5:53 AM
Ishan
Ishan - avatar
+ 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 .
15th Jun 2018, 2:32 AM
Ishan
Ishan - avatar
+ 2
Akib Reza Double quotes will throw errors .Try compiling ur solution .
15th Jun 2018, 2:36 AM
Ishan
Ishan - avatar
+ 1
Yah, got it. Thanks ishan i forgot.(Haven't coded cpp in a while)
15th Jun 2018, 4:47 AM
Akib
Akib - avatar
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
15th Jun 2018, 2:31 AM
Gabriel Cardoso
Gabriel Cardoso - avatar
0
😂😂 Ok. Have fun.
15th Jun 2018, 2:32 AM
Akib
Akib - avatar
0
Is that at school they use compilers online :( Thanks for the attention people.
15th Jun 2018, 2:36 AM
Gabriel Cardoso
Gabriel Cardoso - avatar