Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Every problem starts with a Problem Statement. It tells you in detail about the task to be solved.
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.
The task is very simple: given two integers A and B, write a program to add these two numbers and output it.
This section tells you the format in which your program should receive the 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.
This section tells us the format in which your program should give the output
For each test case, add A and B and display the sum in a new line.
Everything your program prints is considered “output”, so if you output some debugging statements like “Please enter T”, this will be considered as part of your answer, and because it does not satisfy the output format, it will be marked wrong, even if your answer is otherwise correct!
This section tells you the maximum and minimum possible values the variables in the problem statement can take. You do not need to check these constraints in your program. You can safely assume that the input given to your program will be in the given range of constraints.
Input:
3
1 2
100 200
10 40
Output:
3
300
50
#Read the number of test cases.
T = int(input())
for tc in range(T):
# Read integers a and b.
(a, b) = map(int, input().split(' '))
ans = a + b
print(ans)
#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int a,b;
while(n--){
int sum=0;
cin>>a>>b;
sum=a+b;
cout<<sum<<"\n";
}
return 0;
}
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
// Remember that the class name should be "Main" and should be "public".
public class Main {
public static void main(String[] args) {
// System.in and System.out are input and output streams, respectively.
InputStream inputStream = System.in;
InputReader in = new InputReader(inputStream);
// Read the number of test casese.
int T = in.nextInt();
while (T-- > 0) {
// Read the numbers a and b.
int a = in.nextInt();
int b = in.nextInt();
// Compute the sum of a and b.
int ans = a + b;
System.out.println(ans);
}
}
static class InputReader {
public BufferedReader reader;
public StringTokenizer tokenizer;
public InputReader(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream), 32768);
tokenizer = null;
}
public String next() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public int nextInt() {
return Integer.parseInt(next());
}
}
}
In our experience, we suggest you solve this Add Two Numbers CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
If you are stuck anywhere between any coding problem, just visit Queslers to get the Add Two Numbers CodeChef Solution
I hope this Add Two Numbers CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.
This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.
Keep Learning!
More Coding Solutions >>