77.6k views
1 vote
Given an int variable i that has already been declared, write a for loop that prints the integers 0 through 39, separated by spaces. Use no variables other than i.

1 Answer

3 votes

Answer:

The first thing is to define the programming language in which the program will be made, I select C ++ because it seems to me one of the most common and easiest to handle.

We are asked to create a loop of numbers between 0 and 39. In this case it is best to create a counter (i), between starting at 1 and ending at 9, this is done using the "for" command and then to print on screen the command "cout" is used, and lastly "\ n" is used to create the space they ask for.

Therefore the program would look like this, remember that "{}" is to open and close the program.

for (i = 0; i <= 39; i ++) {

cout << i << '\ n';

}

User Resurrection
by
4.8k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.