Simple Operation

Limits: 1s, 512 MB

Mr. X is a school teacher. He teaches C programming to the students. In every class, he gives some simple problems to the students as a class task. One day he asked his students to solve a simple problem. That is, he will give two numbers and an arithmetic operator ( +, - , * ) in the middle of the two numbers. Students have to find out the result after the arithmetic operation. For example, Mr. X has given β€œ10 * 20”. So, the result will be 200.

This is a companion discussion topic for the original entry at

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?


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;
if(d==c || d==g){
else if(f==c || d==g){
return 0;



  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