I m not getting how the even row has printed. In the true expression of while loop we have (col<=row-2) so how 1001 will get printed if row=4
Please explain the dry run of else statement
@Tanvi-Varshney-250726472940778
col = 1;
cout << "1"; //this will print "1"
while (col <= row-2) {
cout << "0";
col = col + 1;
} //this loop will run "row-2", ie "2" times
// so now the output is "100"
cout << "1"; // this will print the last 1, making the output "1001"
1 Like
Thnku to clear my doubt
1 Like
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.