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

main() {char a[10]={1,2,3,4,5,6};int x; for(x=0;x<4;x++){ b[x]=x+'a';} printf("%s",b);}

3 Answers  


Can we replace the struct function in tree syntax with a union?

0 Answers   Huawei,


How to declare a variable?

0 Answers  


An integer that indentifies the position of a data item in a sequence of data items a) value b) number c) index d) all of the above

0 Answers  


How can I read in an object file and jump to locations in it?

0 Answers  






What is the difference between strcpy() and memcpy() function in c programming?

0 Answers  


Explain how can you determine the size of an allocated portion of memory?

0 Answers  


Why we use conio h in c?

0 Answers  


what type of errors are checked during compilation

3 Answers  


What are the types of operators in c?

0 Answers  


how to go with this?

1 Answers   Wipro,


Given an array of numbers, except for one number all the others occur twice. Give an algorithm to find that number which occurs only once in the array.

6 Answers  


Categories