Add Two Numbers Codechef Solution

Add Two Numbers Codechef Solution

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 Solution 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 Solution 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 Solution 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;
	}
}

Disclaimer: The above Problem (Add Two Numbers) is generated by  CodeChef but the solution is provided by Chase2learn.This tutorial is only for Educational and Learning purpose.

Leave a Comment