Create a new variable from one you already have.
What to build
A program that uses a second variable. The line that reads the age is written for you.
Requirements
- Declare a variable
next, holding the age plus one. - Print
Next year you will be N.
Input
One whole number.
Output
One line.
Constraints
The age is from 0 to 150.
Example
Input:
19
Output:
Next year you will be 20
Why it works
next gets its value from age once. Afterwards, the two variables are separate boxes in memory.
Examples
Example 1 · Input
19
Expected output
Next year you will be 20
Example 2 · Input
0
Expected output
Next year you will be 1
Hints
Hint 1
Declare a new int and give it the value age + 1.
Hint 2
%d prints an int.
Solution
Show one correct solution (try it yourself first)
#include <stdio.h>
int main(void) {
int age;
scanf("%d", &age);
int next = age + 1;
printf("Next year you will be %d\n", next);
return 0;
}