0
Why doesn't it stop after printing it 20 times ?
#include <iostream> using namespace std; int main () int a; int c = 1; cout << "Please Enter A Number \n"; cin >> a; cout << "Thank you \n"; for (c < 20; c++;) { cout << a * c << endl; }
5 Respuestas
+ 3
write loop like that
for(;c<20;c++) and put a } to terminate the loop
+ 2
i think mistake is in for loop
for (;c <20;c++)
for (initialization; expression; increment/decrement )
+ 1
Thank you both !
0
Please have a look at for syntax, (initialize; condition; operation)
0
@Balaji
I am aware of how for syntax works, but didn't know that if I declared variable earlier, I needed to put a semicolon as the 'init' and thus, left it blank.