cpp | SoloLearn: Learn to code for FREE!

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 .

c++

8/21/2019 3:54:21 AM

Mahmoud Hamed

1 Answer

New Answer

+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.