Add Two Numbers Codechef Solution

Hello Programmers In this post, you will know how to solve the Add Two Numbers Codechef Solution.

Ezoicreport this adAdd Two Numbers Codechef Solution
Add Two Numbers 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

Shivam is the youngest programmer in the world, he is just 12 years old. Shivam is learning programming and today he is writing his first program.

Program is very simple, given two integers A and B, write a program to add these two numbers.

Input

The first line contains an integer T, the total number of test cases. Then follow T lines, each line contains two Integers A and B.

Output 

For each test case, add A and B and display it in a new line.

Constraints

  • 1 <= T <= 1000
  • 0 <= A, B <= 10000

Example 

Input 

3
1 2
100 200
10 40

Output 

3
300
50

Add Two Numbers CodeChef Solutions in Python

N = int(input())
while N > 0:
    x, y = map(int, input().split())
    sum = x + y
    print(sum)
    N = N - 1

Add Two Numbers CodeChef Solutions in CPP

#include <bits/stdc++.h>
using namespace std;
int main() {
    // Read the number of test cases.
    int T;
    scanf("%d", &T);
    int i=0;
    while (i<T) {
        // Read the input a, b
        int a, b;
        scanf("%d %d", &a, &b);
        // Compute the ans.
        int ans = a + b;
        printf("%d\n", ans);
        i++;
    }
    return 0;
}

Add Two Numbers 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 int solve(int A, int B) {
		return A + B;
	}
}
Ezoicreport this ad

Disclaimer: The above Problem (Add Two Numbers) 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.

Next: ATM Codechef Solution

Sharing Is Caring

Leave a Comment

Ezoicreport this ad