Pattern triangle


please correct my code with explanation

Hi @Ankur-Ankur-937479863269311
In the third for loop you have to decrement val instead of incrementing and before starting of that loop instead of using val=row you have to do val=val-2;

Here is your corrected code :

1 Like

Will you please tell me the error here it is compiling but giving me the wrong answer .i hope you got the idea

Val=val-2
For (val=1, val<=row-1;val++)
Cout<<val-1<<endl;

Val=row
For (val=1, val<=2*row-1; val++)
Cout<<val<<endl;