Diff between for loop and while loop?

Answers were Sorted based on User's Feedback



Diff between for loop and while loop?..

Answer / keerthana

for loop is executed the condition is satified ..the loop
is executed. ex: n=5 ..the loop is 5 times executed..becoz
the condition is true..otherwise loop is exit.

while loop is executed the condition is true..otherwise
after one time..executed until the condition is false..

Is This Answer Correct ?    15 Yes 5 No

Diff between for loop and while loop?..

Answer / naresh lingampally

In both the loops the Out put is same.... but the compile
structure is different:

i.e..,
syn: for(i=0;i<=10;i++)
{
statement;
}

while(i<=10)
{
statement;
i++;
} .

i=0; --> initialization.---{1)
i<=10;---> conditioning ---(2)
i++; ---> incrementation ---(3)


in (while) the compiler order would be
(1) .. not along with the loop
(2),(3) in the loop

but in (for) the order is (1),(2),(3) in a single statement.

NOTE: MAJOR DIFFERENCE IS WE CAN REDUCE THE LENGTH OF THE
PROGRAM (FOR) NAD IS MORE SOPHISTICATED.

Is This Answer Correct ?    4 Yes 2 No

Post New Answer

More C Interview Questions

What are types of structure?

0 Answers  


What is "Duff's Device"?

0 Answers   Celstream,


why we need function pointers?

3 Answers  


How would you sort a linked list?

1 Answers  


What is the use of structure padding in c?

0 Answers  


do ne body have any idea about the salary for the we r going to have interview. yup .. u got it right ..i m talking abt NIC.

1 Answers  


What is the purpose of macro in C language?

0 Answers   Fidelity,


What is the difference between char array and char pointer?

0 Answers  


What is #define used for in c?

0 Answers  


What is structure packing ?

2 Answers   HP,


Describe wild pointers in c?

0 Answers  


Explain what are header files and explain what are its uses in c programming?

0 Answers  


Categories