Compound statement is used to group some statements. We can write compound statement between brackets. Compound statement can be used as a part of loop or branching.
#include <iostream>
using namespace std;
int main(){
for(int i=0;i < 5; i++)
cout << "-" << i;
cout << endl;
return 0;
}
Branching and loop only use one statement if there is no brackets. There will be difference if you put 2 statements after for between brackets.
#include <iostream>
using namespace std;
int main(){
for(int i=0;i < 5; i++)
{
cout << "-" << i;
cout << endl;
}
return 0;
}