easy
0 views

Print the Next Number

Read an integer and print the next consecutive integer (N+1)

Understand the Problem

Problem Statement

The program must accept a number and print its next number.

Constraints

  • Input number must be a valid integer within standard integer range
  • Output will be the input number incremented by 1
  • No special handling required for edge cases

Examples

Example 1
Input
5
Output
6
Explanation

When the input is 5, the next consecutive integer is 5 + 1 = 6

Example 2
Input
99
Output
100
Explanation

When the input is 99, the next consecutive integer is 99 + 1 = 100

Solution

#include <stdio.h>

int main() {
    int N;
    scanf("%d", &N);
    printf("%d", N + 1);
    return 0;
}
Time:O(1)
Space:O(1)
Approach:

C Solution Explanation:

  1. #include <stdio.h> - Include standard input/output library
  2. int main() - Main function entry point
  3. int N; - Declare integer variable to store input
  4. scanf("%d", &N); - Read integer from standard input using format specifier %d
  5. printf("%d", N + 1); - Print the result of N + 1 using format specifier %d
  6. return 0; - Return 0 to indicate successful execution

Visual Explanation

Loading diagram...