Add two numbers solution in C language.- Codechef

ADD TWO NUMBERS

Problem Code: FLOW001


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

  •  T  1000
  •  A,B  10000

Example

Input
3 
1 2
100 200
10 40

Output
3
300
50

. . .


Solution in C.


#include <stdio.h>
int main() {
    int T;
    scanf("%d", &T);
    while (T--) {
        int a, b;
        scanf("%d %d", &a, &b);
        int ans = a + b;
        printf("%d\n", ans);
    }
    return 0;
}


Explanation:-
  1. First take the input T (total number of test cases).
  2. Use while loop (until T>0).
  3. Take two variables a and b as input from user.
  4. Do addition of a and b using arithmetic operator '+'.
  5. Display the ans obtained by adding a and b printf().


Try above code on C-Playground :- https://bit.ly/3gtHZIW



Comments

Popular posts from this blog

ATM solution in C language.- Codechef

MOTIVATION SOLUTION IN C LANGUAGE | CODECHEF | IMDB

APPLE AND ORANGE | HACKERRANK | PROBLEM SOLVING | SOLUTION IN C