## Read the description of chef and operators problem

This chef and operators program will take an integer which will be the testcase and then we have to give two integer for each test case. This program will check the given two integer that which is the biggest among them. Then we will print the output according to that.

We have taken it from CodeChef for practice and learning purpose only. We will discuss the problem and see a solution of this problem which will help the beginner programmer to go ahead in their journey. Don’t just depend upon our solution, rather you should try to solve it in your own. So, try this.

Don’t worry, if you are confusing about the problem then we have given a simple solution to chef and operator problem which is given bellow.

## Solution of chef and operators problem

At first we have to take the testcase from the user. The we will use a for loop to take the input for each test case. You can use any loop to do this.

For each test case we will take two integers from user and check the condition using if else statement. If first number is greater then second, we will print ‘>‘ sign. If the second number is greater than first number, we will print ‘<‘ sign. Otherwise we will print ‘=‘ sign.

Consider a user give two integer 15 and 20.

Then we check that 15Â  <Â  20 and print ‘<‘.

Again if he give two number 25 and 15.

Then we know that 25Â  >Â  15 and print ‘>‘.

If the given two number is same, then we will print ‘=‘.

Now, let’s go to the C solution of chef and operators problem.

``````// solution of chef and operators problem

#include <stdio.h>

int main(){
int T, c;
scanf("%d", &T);

for(c = 1; c <= T; c++){
int  x, y;
scanf("%d %d", &x, &y);

if(x > y){            // check if x > y
printf(">\n");
}else if(x < y){      // check if x < y
printf("<\n");
}else{                // default which is x = y
printf("=\n");
}

}
return 0;
}``````

### Output of chef and operators problem

After compiling and running the above program you will see the following output.

``````3
10 20
<
20 10
>
10 10
=``````

First line contains 3 which it the number of test case for this problem. Then the user gives two integer 10 and 20 where 10 < 20 and for this we have printed ‘<‘ here. Second input is 20 and 10 where the program have printed ‘>‘ sign on the screen. And it has printed ‘=‘ sign for the third test case.

Now, you should try this problem using different loop like while loop and do while loop. If you use other programming language then the logic will be same.

Previous page:Â  Sum or difference

Next page: Â Reverse the number

Recommended for you: