easy
0 views
Add Two Numbers
Calculate and print the sum of two given integers.
Understand the Problem
Problem Statement
Accept two numbers and print their sum.
Constraints
- Input consists of two integers separated by space
- Each integer can be within standard integer range
- Output should be a single integer representing the sum
Examples
Example 1
Input
10 20Output
30Explanation
The sum of 10 and 20 is 30.
Example 2
Input
137 11Output
148Explanation
The sum of 137 and 11 is 148.
Solution
#include <stdio.h>
int main() {
int X, Y;
scanf("%d %d", &X, &Y);
printf("%d", X + Y);
return 0;
}Time:O(1)
Space:O(1)
Approach:
C Solution Explanation:
#include <stdio.h>- Include standard input/output libraryint X, Y;- Declare two integer variablesscanf("%d %d", &X, &Y);- Read two integers from stdinprintf("%d", X + Y);- Print the sum of X and Yreturn 0;- Exit successfully
Visual Explanation
Loading diagram...