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 is sizeof return in c?

1 Answers  


Find Index of least significant bit set in an Integer. ex. int value is say 10001000 results should be 4.

1 Answers  


Explain what is dynamic data structure?

1 Answers  


Explain continue keyword in c

1 Answers  


in malloc and calloc which one is fast and why?

1 Answers  


2)#include<iostream.h> main() { printf("Hello World"); } the program prints Hello World without changing main() the o/p should be intialisation Hello World Desruct the changes should be a)iostream operator<<(iostream os, char*s) os<<'intialisation'<<(Hello World)<<Destruct b) c) d)none of the above

4 Answers   Siemens,


what do u mean by Direct access files? then can u explain about Direct Access Files?

1 Answers   LG Soft,


how can u print a message without using any library function in c

1 Answers   NIIT,


What is string in c language?

1 Answers  


Describe the steps to insert data into a singly linked list.

1 Answers  


Explain high-order and low-order bytes.

1 Answers  


What is I ++ in c programming?

1 Answers  


Categories