-
Notifications
You must be signed in to change notification settings - Fork 0
/
Add Two Numbers
56 lines (43 loc) · 1.7 KB
/
Add Two Numbers
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Problem
Problem Statement
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.
Input Format
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.
Output Format
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!
Constraints
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.
1 ≤ T ≤ 1000
0 ≤ A,B ≤ 10000
Sample 1:
Input
Output
3
1 2
100 200
10 40
3
300
50
Answer :
#include <bits/stdc++.h>
using namespace std;
int main() {
// Read the number of test cases.
int T;
cin >> T;
for (int i = 1; i <= T; i++) {
// Read the input a, b
int a, b;
cin >> a >> b;
// Compute the ans.
int ans = a + b;
cout << ans << "\n";
}
return 0;
}