Ok so i was working on some programs given in my text book which is
{
int n,k;
n=1;
while(n<=5){
cout<<"\n";
for(k=1;k<=n;k++)
cout<<k<<" ";
n++;
}
}
the output isenter image description here but after that when i added braces in for loop it burst
{
int n,k;
n=1;
while(n<=5){
cout<<"\n";
for(k=1;k<=n;k++){
cout<<k<<" ";
n++;}
}
}
enter image description here SO can anyone explain why this happen's?