i know the code but still confuse that how it works?
Can any body explain how this code works,,, cuz the "*" is not mentioned in any integer so how integers work on it...
{
for (int i=0;i<=20;i++)
{
for (int j=0;j<=i;j++)
{
cout<<'*';
}
cout<<endl;
}
system("pause");
}
The outer loop runs once then -> inner for loop is going to run 1 time.... then exit out to the outer loop....then back into the inner loop...the inner loop is going to run 2 times.... back out to the outer loop...then back into the inner loop.... then, the inner loop runs 3 times.....and it keeps doing that up to 20 times...
***The amount of times the inner "food loop" runs before it exits out to the outer loop, is based on the variable "i" of the outer loop which increments each time after the inner loop has finished.
Hope this helps i remember having trouble understanding this
Run this code this will solidify your understanding after you look at it for a few minuets.