Diff between for loop and while loop?
Answers were Sorted based on User's Feedback
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 |
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 |
Explain what is the difference between the expression '++a' and 'a++'?
Can you define which header file to include at compile time?
What is the significance of scope resolution operator?
0 Answers Agilent, ZS Associates,
Is c call by value?
i have to apply for rbi before that i need to know the the syllabus for the entrance questions. whethet it may be aps or techinical
Why doesnt the call scanf work?
write a program to remove occurrences the word from entered text?
How can you determine the maximum value that a numeric variable can hold?
What are the back slash character constants or escape sequence charactersavailable in c?
Illustrate it summing the series 2+4+6+......to n terms using (i) while loop (ii) do-while loop
What is scope and lifetime of a variable in c?
What is a class?