Help me in solving LOOP2V2 problem

My issue

Hey! I have just started learning C++. Based on the code written below, can one explain why in L9, using semicolon at the end gives wrong answer, and why does L11 has to be written inside curly brackets.

My code

#include <bits/stdc++.h>
using namespace std;

int main() {

  int num;
  cin >> num; 
int a = 0;
while (a < num)
{cout << a << endl;
a = a + 1;
}




  return 0;
}

Learning course: Learn C++
Problem Link: CodeChef: Practical coding for everyone

@shreyas735
u have to do it like this:-

#include <bits/stdc++.h>
using namespace std;

int main() {

  int num;
  cin >> num; 
  int a = 0;
  while (a < num ) {
    cout << a << endl;
    a = a+1;
  }

  return 0;
}