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 |
2. What is the function of ceil(X) defined in math.h do? A)It returns the value rounded down to the next lower integer B)it returns the value rounded up to the next higher integer C)the Next Higher Value D)the next lower value
WHAT IS HEADER?
What's wrong with "char *p; *p = malloc(10);"?
int i=10; printf("%d %d %d", i, i=20, i);
What are dangling pointers? How are dangling pointers different from memory leaks?
What are the 4 types of unions?
Write a program to check prime number in c programming?
I need to take a sentence from input and sort the words alphabetically using the C programming language. Note: This is C not C++. qsort and strtok not allowed
What is union and structure in c?
What are the storage classes in C?
Explain how do I determine whether a character is numeric, alphabetic, and so on?
What are the types of arrays in c?