10.6k views
5 votes
Write a program using loops in C, that takes an integer input from the user, and prints out next five integers. (Note: Submit the code as handwritten)

User Liron Levi
by
7.5k points

1 Answer

4 votes

Final answer:

The student's query is addressed by providing a C program that uses a loop to print out the next five integers after the user inputs an initial number.

Step-by-step explanation:

A student looking to write a program in C that prints the next five integers after an input value can use a simple for loop to accomplish this. Below is a basic example of such a program:

#include
int main() {
int i, number;
printf("Enter an integer: ");
scanf("%d", &number);
for(i = 1; i <= 5; i++) {
printf("%d\\", number + i);
}
return 0;
}

This code will prompt the user for an integer, then use a loop to print out the next five integers. It is a good example of how loops can be used effectively for iteration in C programming.

User FabKremer
by
8.4k points