79.7k views
5 votes
Write lines of code using FOR loop to display all the integers from 1 through 100 (inclusive)

User Berta
by
7.5k points

1 Answer

0 votes

Answer:

#include <iostream>

using namespace std;

int main() {

for(int i=1; i<=100; i++) {

cout << i << " ";

}

return 0;

}

Step-by-step explanation:

This code will loop through the values of i from 1 to 100 (inclusive) and print each value to the console using the cout statement. The loop variable i is initialized to 1, and the loop continues as long as i is less than or equal to 100. In each iteration of the loop, the value of i is printed to the console using the cout statement. Finally, the return 0; statement is used to indicate that the program has executed successfully.

User Feldur
by
7.3k points