Hello Programmers In this post, you will know how to solve the Chef And Operators Codechef Solution.
One more thing to add, don’t directly look for the solutions, first try to solve the problems of Codechef by yourself. If you find any difficulty after trying several times, then you can look for solutions.
Problem
Chef has just started Programming, he is in first year of Engineering. Chef is reading about Relational Operators.
Relational Operators are operators which check relationship between two values. Given two numerical values A and B you need to help chef in finding the relationship between them that is,
- First one is greater than second or,
- First one is less than second or,
- First and second one are equal.
Input
First line contains an integer T, which denotes the number of testcases. Each of the T lines contain two integers A and B.
Output
For each line of input produce one line of output. This line contains any one of the relational operators
‘<‘ , ‘>’ , ‘=’.
Constraints
- 1 <= T <= 10000
- 1 <= A, B <= 10000000001
Example
Input:
3 10 20 20 10 10 10
Output:
< > =
Chef And Operators CodeChef Solutions in Python
T = int(input()) while T > 0: m, n = map(int, input().split()) if m > n: print(">") elif m < n: print("<") else: print("=") T = T - 1
Chef And Operators CodeChef Solutions in CPP
#include <stdio.h> int main() { int testcase; long long num1,num2; scanf("%d",&testcase); while(testcase--) { scanf("%lli %lli",&num1,&num2); if (num1<num2) printf("<\n"); else if(num2<num1) printf(">\n"); else printf("=\n"); } return 0; }
Chef And Operators CodeChef Solutions in JAVA
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); for (int tc = 0; tc < T; tc++) { int A = sc.nextInt(); int B = sc.nextInt(); System.out.println(solve(A, B)); } sc.close(); } static char solve(int A, int B) { if (A < B) { return '<'; } else if (A > B) { return '>'; } else { return '='; } } }
Disclaimer: The above Problem (Chef And Operators) is generated by CodeChef but the solution is provided by BrokenProgrammers. This tutorial is only for Educational and Learning purpose.
Note:- I compile all programs, if there is any case program is not working and showing an error please let me know in the comment section. If you are using adblocker, please disable adblocker because some functions of the site may not work correctly.