0

Why there is no output? Is there suppose to have Number=1,Number=2,Number=3...until 5?

#include <iostream> using namespace std; int main() { int num = 1; if (num=3){ num+=3; } else { num= 1; } while (num < 6) { cout << "Number: " << num << endl; num++; } return 0; }

10th Feb 2018, 12:26 PM
GO
GO - avatar
2 Answers
+ 6
you are setting it equal to (=) instead of testing for equality (==) ... If num==3
10th Feb 2018, 12:34 PM
Louis
Louis - avatar
0
Thank you! Oh that "else" is useless over here.
10th Feb 2018, 11:13 PM
GO
GO - avatar