Knowee
Questions
Features
Study Tools

Your task is very simple: given two integers š“A and šµB, write a program to add these two numbers and output the sum.Input FormatThe 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 FormatFor each test case, add š“A and šµB and display the sum in a new line.Constraints1ā‰¤š‘‡ā‰¤10001≤T≤10000ā‰¤š“,šµā‰¤100000≤A,B≤10000Sample 1:InputOutput31 2100 20010 40330050Explanation:Testcase 1: 1+2=31+2=3. Hence the first output is 33.Testcase 2: 100+200=300100+200=300. Hence the second output is 300300.

Question

Your task is very simple: given two integers š“A and šµB, write a program to add these two numbers and output the sum.Input FormatThe 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 FormatFor each test case, add š“A and šµB and display the sum in a new line.Constraints1ā‰¤š‘‡ā‰¤10001≤T≤10000ā‰¤š“,šµā‰¤100000≤A,B≤10000Sample 1:InputOutput31 2100 20010 40330050Explanation:Testcase 1: 1+2=31+2=3. Hence the first output is 33.Testcase 2: 100+200=300100+200=300. Hence the second output is 300300.

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

Here is a Python solution for the problem:

T = int(input())
for _ in range(T):
    A, B = map(int, input().split())
    print(A + B)

Here is how it works:

  1. The first line reads the number of test cases, T.
  2. The for loop runs T times. For each iteration:
    • It reads two integers, A and B, from the input. The map function is used to convert the input strings to integers.
    • It prints the sum of A and B.

This program assumes that the input is well-formed, i.e., there are exactly T lines following the first line, and each of these lines contains exactly two integers separated by a space.

This problem has been solved

Similar Questions

TaskThe provided code stub reads two integers from STDIN, and . Add code to print three lines where:The first line contains the sum of the two numbers.The second line contains the difference of the two numbers (first - second).The third line contains the product of the two numbers.ExamplePrint the following:8-215Input FormatThe first line contains the first integer, .The second line contains the second integer, .

Sum of NumbersYou are given a Python code snippet that aims to find the sum of all numbers from 1 to a given positive integerĀ n. However, some parts of the code are missing. Fill in the missing code to complete the program.Sample Test CasesTest Case 1:Expected Output:EnterĀ·aĀ·positiveĀ·integer:Ā·3TheĀ·sumĀ·ofĀ·allĀ·numbersĀ·fromĀ·1Ā·toĀ·3Ā·is:Ā·6Test Case 2:Expected Output:EnterĀ·aĀ·positiveĀ·integer:Ā·5TheĀ·sumĀ·ofĀ·allĀ·numbersĀ·fromĀ·1Ā·toĀ·5Ā·is:Ā·15

Given a string A. The string contains alphanumeric characters.Find the sum of all numbers present in it.Note: All the numbers will fit in a 32-bit signed integer.Problem Constraints1 <= |A| <= 105Input FormatThe first and only argument is a string A.Output FormatReturn an integer.Example InputInput 1:A = "a12b34c"Input 2:A = "123"Example OutputOutput 1:46Output 2:123Example ExplanationExplanation 1:The numbers are 12, 34.12 + 34 = 46Explanation 2:The only number is 123.

Sum of 2 NumbersGiven an array, check if there exist 2 elements of the array such that their sum is equal to the sum of the remaining elements of the array.Input FormatThe first line of input contains T - the number of test cases. It is followed by 2T lines, the first line contains N - the size of the array. The second line contains N integers - elements of the array.Output FormatFor each test case, print "Yes" if such elements exist, and "No" otherwise, separated by a new line.

Write a program to find the sum of two integers using an inline lambda expression.Input format :The input consists of 2 integers.Output format :The output prints the sum of two integers.Sample test cases :Input 1 :5 6 Output 1 :11Input 2 :-12 7Output 2 :-5Input 3 :-5 -7Output 3 :-12

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.