0
cpp
to make this shape * ** *** **** ***** we write this code #include<iostream> using namespace std; int main(){ int i; for(int row =1; row<=5; row++){ for (int col=1; col<=row; col++){ cout<<"*";} cout<<"\n";} return 0; } so may anyone explain to me why we wrote col<=row in the inner for .
1 ответ
+ 2
row = 1 *
row = 2 **
row = 3 ***
row = 4 ****
row = 5 *****
You can see that the amount of * is followed by row. And we make a new line(\n) when row increases.