Q. What is the loop?
Loop is used to execute a group of instructions or a block of code
multiple times, without writing it repeatedly. The block of code is
executed based on a certain condition. Loops are the control structures of
a program. Using Loops in computer programs simplifies rather
optimizes the process of coding.
Example: suppose if we want to print the good morning 100 times so
better way we can write the 100 printf we can use the loop and we can
execute the single loop 100 times.
Q. Explain The Types Of Loop?
There are two types of loop
1) Entry Control loop : entry control loop means the condition check
at the beginning of the loop and if condition is satisfy then loop will be
executed and if condition is not satisfy then loop will not execute means
in entry control loop first check the condition and then decide loop will
be execute or not .
There are two types of entry control loop in c language
I) While loop
II) For Loop
2) Exit Control loop: exit control loop means the condition check at
the end of loop means in exit control loop first loop get executed and
after that condition check means in exit control loop minimum single
time loop will be executed.
In Exit control loop we have the only one loop name as do while loop.
Q. Explain the important steps in loop execution?
There are three important steps in loop
, 1) Initialization: initialization means we decide the starting point
of loop
2) Condition: condition means decide how many times loop will
be executed means decide the number of iteration in loop.
3) Increment or decrement: increment and decrement means decide
the steps to increment and decrement in loop.
Q. explain the syntax of while loop?
initialization;
while
(condition)
{ write here your logics
Increment or decrement;
}
Example:
int i=1;
while (i
<=5)
{ printf ("Good Morning\n");
i++;
}
Q. Explain the syntax of for loop?
for (initialization; condition; increment or decrement)
{ write here logics
}
e.g
for (int i=1; i<=5; i++)
{ printf ("good morning India");
}
Loop is used to execute a group of instructions or a block of code
multiple times, without writing it repeatedly. The block of code is
executed based on a certain condition. Loops are the control structures of
a program. Using Loops in computer programs simplifies rather
optimizes the process of coding.
Example: suppose if we want to print the good morning 100 times so
better way we can write the 100 printf we can use the loop and we can
execute the single loop 100 times.
Q. Explain The Types Of Loop?
There are two types of loop
1) Entry Control loop : entry control loop means the condition check
at the beginning of the loop and if condition is satisfy then loop will be
executed and if condition is not satisfy then loop will not execute means
in entry control loop first check the condition and then decide loop will
be execute or not .
There are two types of entry control loop in c language
I) While loop
II) For Loop
2) Exit Control loop: exit control loop means the condition check at
the end of loop means in exit control loop first loop get executed and
after that condition check means in exit control loop minimum single
time loop will be executed.
In Exit control loop we have the only one loop name as do while loop.
Q. Explain the important steps in loop execution?
There are three important steps in loop
, 1) Initialization: initialization means we decide the starting point
of loop
2) Condition: condition means decide how many times loop will
be executed means decide the number of iteration in loop.
3) Increment or decrement: increment and decrement means decide
the steps to increment and decrement in loop.
Q. explain the syntax of while loop?
initialization;
while
(condition)
{ write here your logics
Increment or decrement;
}
Example:
int i=1;
while (i
<=5)
{ printf ("Good Morning\n");
i++;
}
Q. Explain the syntax of for loop?
for (initialization; condition; increment or decrement)
{ write here logics
}
e.g
for (int i=1; i<=5; i++)
{ printf ("good morning India");
}