Update of the value of num was done within the body of the loop
#include <iostream> using namespace std; int main(void) { int num = 0; while (num++ < 10) cout << num << " "; return 0; }