Do While loop in C Language

 Do While loop in C Language

#  Do While loop in C Language:- Do While loop is a c, it a specific task  again & again while a particular condition is true. It is a past-tested loop because 1st of all it perform the task after that it test the condition. If condition is true than perform the task again. If the condition is false in the very begning then statement or set of statement in do block will be executed atlist onces.

Syntex of do while loop:- 

do

{

statement(s) ;

}

while( condition ) ;

Example :-

Program: To print my name is preeti as a choice times.

#include<stdio.h>


#include<conio.h>
void main()
{
char choice;
clrscr();
do
{
printf(" my name is preeti \n");
printf(" want to print one more time press y/n  \t");
fflush(stdin);
scanf("%c" , & choice );
}
while (choice=='y');
getch();
}

Output:- 


my name is preeti 
want to print one more time press y/n  y
my name is preeti
want to print one more time press y/n  y

my name is preeti
want to print one more time press y/n  y
my name is preeti
want to print one more time press y/n  y
my name is preeti
want to print one more time press y/n  n


Thank for reading......

Read more:https://www.youtube.com/@Khoobstudy/videos

No comments

Powered by Blogger.