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 |
Can you please explain the difference between syntax vs logical error?
Efficient data structure for store/search list of 1000 records a)array b)double linked list c)circular queue d)hash table
What is #include stdlib h?
WHY DO WE USE A TERMINATOR IN C LANGUAGE?
#include main() { int i=1,j=2; switch(i) { case 1: printf("GOOD"); break; case j: printf("BAD"); break; } }
Why is c called a structured programming language?
Write a C program to count the number of email on text
What is the difference between ++a and a++?
hi friends how r u as soon in satyam my interview is start but i m very confusued ta wat i do plz help me frndz wat can i do plz tell me some question and answers related with "C" which r asked in the interview .
0 Answers Aegis, CDAC, Infosys,
What are the types of pointers?
What is pass by reference in c?
If the size of int data type is two bytes, what is the range of signed int data type?