+ 2

Don't Work if i replace < with =

hello if i replace the while (num < 6) with while (num = 6) the Program don't stopt. why? #include <iostream> using namespace std; int main() { int num = 1; while (num < 6) { cout << "Number: " << num << endl; num = num + 1; } return 0; }

7th Feb 2018, 6:39 AM
Uwe Brin
Uwe Brin - avatar
1 Resposta
+ 8
I think it should be == = is assigning a value while == is comparing values
7th Feb 2018, 6:51 AM
kideoh0jima