Simple Operation

Mr. X is a school teacher. He teaches C programming to the students. In every class, he gives some s…

Click here to read the complete problem statement.


If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.

Hello,
I have attempted to solve this simple problem with JS and got WA in the last test case. I have solved it with C++ , though. Is there any catch? Or, is it just any simple error in the dataset?

Thanks!

Hi @shamin_asfaq, you guessed it right. There was an issue with the dataset. Thank you for bringing this to our attention. Your submissions have been rejudged.

1 Like

#include <stdio.h>

int main() {
int a,b,e;
char d=‘+’,c,f=‘-’,g;
scanf(“%d”,&a);
scanf(“%d%c%d”,&b,&c,&e);
scanf(“%d%c%d”,&b,&g,&e);
if(d==c || d==g){
printf(“%d”,b+e);
}
else if(f==c || d==g){
printf(“%d”,b-e);
}
else{
printf(“%d”,b*e);
}
return 0;
}

problem???

Many.

  1. There can be more operations than 2. You have to read T first and then do T operations.
  2. improper way to read a character. you should put space(s) where you need them. like…
scanf("%d %c %d",&b,&c,&e);
         ^  ^  here
  1. You forgot to print this. Case N: result