2.2 Code Practice: Question 1
Ask the user to input an integer. Print out the next three consecutive numbers.
The following content is partner provided
Answers
Answer:
a = float(input("Enter an integer: "))
print(a + 1)
print (a + 2)
print (a + 3)
Explanation:
please mark my awnser as the brainliest awnser
Below are the c program for the above question
Explanation:
#include <stdio.h>// header file inclusion
int main()// main declaration
{
int a;// declare a variable
scanf("%d",&a);// print the first constitutive number
printf("%d",++a);//print first constitutive number
printf("%d",++a);//print the second constitutive number
printf("%d",++a);//print the third constitutive number
return 0;
}
Output:
- If the input is 3 then the output is 4,5,6.
- If the input is 4 then the output is 5,6,7.
It is because the consecutive number means the next term and the three consecutive number means the next three terms. In the above code, scanf is used for input, printf is used to give output and ++ operator is used to increase the value of a variable by 1.
Learn More:
- Definition of C Program: brainly.in/question/637147
- c program: brainly.in/question/9996665