Page Summary
URI 1001 Problem: Program to Print Sum of 2 Input
URI 1001 Problem solution: In this problem, you have to write a program that takes 2 input and print the sum as output.
Read also>
According to URI Online judge, problem 1001 is given below:
Read 2 variables, named A and B, and make the sum of these two variables, assigning its result to the variable X. Print X as shown below. Print endline after the result otherwise you will get “Presentation Error”.
Input
The input file will contain 2 integer numbers.
Output
Print the letter X (uppercase) with a blank space before and after the equal signal followed by the value of X, according to the following example.
Obs.: don’t forget the endline after all.
Input Sample | Output Sample |
---|---|
10 9 | X = 19 |
-10 4 | X = -6 |
15 -7 | X = 8 |
URI 1001 Solution in C
Program:
#include<stdio.h> main() { int a,b,c; scanf("%d%d", &a, &b); c = a + b; printf("X = %d\n", c); }
Or
#include<stdio.h> int main() { int a,b; scanf("%d%d", &a, &b); printf("X = %d\n", a+b); }
Input:
This is a test input in C: 10 9
Output:
This is the output of test input: X = 19
To run this code (URI 1001 Solution/Answer) on your Laptop or PC, download Code::blocks, and to run in your android mobile download CppDroid – C/C++ IDE from play store or you can simply search on google Online C Compiler or Online C++ Compiler, you’ll get plenty of online compilers! Try them!