What is the diffrent between while and do while statement ?




Answers were Sorted based on User's Feedback



What is the diffrent between while and do while statement ?..

Answer / namrata

In while first condition is checked if condition is not true
then while don't work and not give output but in do while
loop condition is checked when loop is worked at one time
and if the condition is not true then at least one time it
gives output it is the main difference between while & do
while loop.

Is This Answer Correct ?    20 Yes 2 No

What is the diffrent between while and do while statement ?..

Answer / mahfooz

while(//condition checking)
{//if condition is true go inside loop.and its first check
condition then go inside loop.
}
but in do{
}while(//condition checking)..
it wiil go in loop first and then check condition..
it will go iside loop atleast one time..but in while it
may not go even in single time..

Is This Answer Correct ?    9 Yes 1 No

What is the diffrent between while and do while statement ?..

Answer / ashok

(1)while loop is known as entry control loop.
and do while is known as exit control loop.

(2)in while loop first check given the condition & if it is
true then execute all statement of while loop.if it is
false then terminate control from loop.
and in do while loop first execute all statement of it and
then check condition, if yes it is true, then again do
while loop will execute, if it is false then terminate
control from loop,put semicolon after while statement.

Is This Answer Correct ?    7 Yes 2 No




What is the diffrent between while and do while statement ?..

Answer / shwetha karkera

In WHILE STATEMENT, the condition is tested first, and then
the statements are executed if the condition turns out to
be true. hence, it is calles as PRE-TESTED LOOPING
CONSTRUCT.

In DO WHILE STATEMENT,the statements are executed for the
first time and then the conditions are tested. if the
condition turns out to be true,then the statements are
executed again.hence it is called as POST-TESTED LOOPING
CONSTRUCT.

SYNTAX FOR WHILE STATEMENT:
while(condition)
{
statement;
}


SYNTAX FOR DO WHILE STATEMENT:
Do
{
statement;
}
while(condition)

Is This Answer Correct ?    5 Yes 0 No

What is the diffrent between while and do while statement ?..

Answer / vaibhav

the while statement first check the condition & then
exicute a statement & do while first exicute a stat. & then
check condi. . do while loop can exicute one time even
condi. is false

Is This Answer Correct ?    6 Yes 2 No

What is the diffrent between while and do while statement ?..

Answer / ishwor pandey

in while first conditionis checked if condition is not true

Is This Answer Correct ?    1 Yes 4 No

Post New Answer



More C Interview Questions

what is the self-referential structure?

1 Answers  


how the compiler treats any volatile variable?Explain with example.

1 Answers   Tata Elxsi,


output for following code??? main() { int x=2,y,z; x*=3+2; printf("1.%d\n",x); x*=y=z=4; printf("2.%d %d %d\n",x,y,z); x=y==z; printf("3.%d\n",x); x==(y=z); printf("%d",x); }

2 Answers   Elysium,


helllo sir , what is the main use of the pointer ,array ,and the structure with the example of a programe

2 Answers  


void main() {int i=2; printf("%d%d%d",i,++i,i++); getch(); }

9 Answers  






Why do u use # before include in a C Progam?

9 Answers   IBM,


When you call malloc() to allocate memory for a local pointer, do you have to explicitly free() it?

2 Answers   Aloha Technology,


I need previous papers of CSC.......plz help out by posting them.......

0 Answers  


Is there something we can do in C but not in C++? Declare variable names that are keywords in C++ but not C.

2 Answers   Infosys,


when user give a number it multiply with 9 without useing '+' and '*' oprator

4 Answers  


To print the pattern 1 2 3 4 5 10 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9

0 Answers   HCL,


# define x=1+4; main() { int x; printf("%d%d",x/2,x/4); }

5 Answers  






Categories