Urgenthomework logo
UrgentHomeWork
Live chat

Loading..

The do while loop

The syntax of Do-While Loop is:

do
{
this;
and this; this too;
…..
etc;
}


while (if the condition is true)

In Do-While Loop the statements are evaluated first and then the conditions are checked.

In While Loop if the condition fails to satisfy then the statements will not be executed however in Do-While Loop, it will be evaluated once even if the condition fails.



#include < stdio.h >
void main()
{
char inchar;
do
{
printf(“Input Y or N”);
scanf(“%c”, &inchar);
}
while(inchar!=’y’ && inchar != ‘n’);

if(inchar==’y’)
printf(“you pressed u\n”);
else
printf(“You pressed n\n”);
}


homework help with do while loop

Topics in C Programming

Copyright © 2009-2023 UrgentHomework.com, All right reserved.