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 20
Output
30
Explanation

The sum of 10 and 20 is 30.

Example 2
Input
137 11
Output
148
Explanation

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:

  1. #include <stdio.h> - Include standard input/output library
  2. int X, Y; - Declare two integer variables
  3. scanf("%d %d", &X, &Y); - Read two integers from stdin
  4. printf("%d", X + Y); - Print the sum of X and Y
  5. return 0; - Exit successfully

Visual Explanation

Loading diagram...