115k views
1 vote
Write a repetition statement that outputs the numbers 45 , 51 , . . . , 165 . That is, all of the multiples of 6 in increasing order, starting at 45 and ending at 165 . #include Using namespace std; Int main( ) { Int i = 45; For ( i = 45; i <=165; i = i + 6) Count << i << endl; System("pause"); }

User Althea
by
6.4k points

1 Answer

3 votes

Answer:

#include <iostream>

using namespace std;

int main()

{

int i = 45;

for ( i = 45; i <=165; i = i + 6)

cout << i << endl;

}

Step-by-step explanation:

I corrected your code and highlighted the mistakes. Even though you wrote the correct algorithm, your code did not compile because of the typos you made.

Remember, C++ is a case-sensitive language. That means, "For" is not same as "for".

Generally, variables and keywords are written in lower case. Of course, there are exceptions, such as constant variables are all written in uppercase letter and class names start with an uppercase letter.

User Jim Davis
by
6.2k points