Question

Convert the following nested do-while loop into a nested for loop:
i = 0;
do
{
i = i+1;
j = i;
do
{
if( (i+j)%2 == 0 )
printf("%d", i);
else
printf("%d", j);
j = j+2;
}while(j < = 10);
}while(i <= 5);
Verify that you get the same output in each case.

19 Mar 2023
Answer :
Word Count : 326

The nested do-while loop that needs to be converted to a nested for loop:

i = 0;

do

{

i = i+1;

j = i;

do

{

if( (i+j)%2 == 0 )

printf("%d ", i);

else

printf("%d ", j);

j = j+2;

}while(j <= 10);

}while(i <= 5);

 

The equivalent nested for loop:

 

for (int ___ ____ _____ _______ _____ ______ __________ ________ ____ ____ ____.
____ ________ ________ ________ _____ __________ _________ _________ __________ _______.
_________ ___ __________ ____ ______ _________ ___ ______ _________ ____ ____.
__________ ________ _________ __________ _____ ______ ______ ________ ______ ____ _______.
__________ __________ _______ _______ ________ ______ __________ _________ ___ _________ ________ ___.
____ _________ _______ ________ ____ _________ ________ __________ ______ __________ ____.
_________ ___ __________ __________ ________ _______ _______.
__________ __________ ________ _____ _______ ______ _______ _______ ___ _______ _________.
_________ _____ _______ _____ _______ __________ __________ ___ ________ _________.
_______ ______ __________ ____ ______.
________ _____ ________ _____ ____ _________ __________ _______ ___ _________ _________ ___.
_____ _________ ___ ______ ______.
____ __________ ________ ____ __________ _________ ________ __________ __________.
________ _______ _______ _________ ________ ___ ___ ________.
_____ __________ ____ ______ ___ __________ ________.
___ __________ _____ _________ _________ __________.
_________ __________ __________ _________ _________ _____ ______.
_______ ________ ___ ________ __________ _________ ______ _____ ____ _________ ____ __________.
_________ __________ ____ ___ ____ _________ _______ ______ _______ ____.
_______ ___ ______ _________ ________ ________ ___ _____ _______ ____ _____ _____.
_____ _____ ___ ____ ___ ___ _____.
________ _________ _____ __________ _______ _____ _______ _______ ____ _________ ____ ________.
______ __________ ________ _________ _________ _____ ____.
__________ ________ ____ ________ ___ _________ ___ ___ _________ ________ ____ __________.
_____ ___ ___ _________ ___ ___ __________.
________ ____ _________ _______ _____ _____ ____ ______ ______ ________ _________ _______.
_________ _______ _______ ________ _________ ________ ____ _________ _________.
_______ ___ _____ _________ _________ _____ ______ ____.
Get Full Answer on WhatsApp

IGNOU NEWS
Assignment Submission Last Date Extended Till 30 June 2026 Click Here★★★IGNOU June 2026 TEE Date Sheet Released Click Here★★★
Top
📞
Call Support Instant phone assistance Convert the following nested do-while loop into a nested for loop:i
🟢
WhatsApp Chat Fast live messaging
Email Us Business enquiries & support