Generate the odd numbers from 15 to 53 (inclusive)? In a FOR loop as well. I have no idea how to make this program.
I tried at it, with while as well. But in the output it just kept repeating 15 in an infinite loop. Can anyone change this to for and fix it so it works? and tell me what I did wrong? Thanks!
Also if you want multiple statements within a loop, you need to enclose them in braces. Right now, only the first statement printing out the number is looping. It never gets to the incrementing statement.
1 2 3 4 5
while (Number<=53)
{ // add opening brace to have multiple statements in while loop
cout << Number << "\t" <<endl;
Number = Number + 2;
} // end while loop brace
1 2 3 4 5 6 7 8 9 10 11
#include <iostream>
usingnamespace std;
int main()
{
for (int i=15; i<=53; i+=2)
cout << i << "\t" << endl;
return 0;
}