Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

http://studysolutions.

org

ICS Notes Computer Science Part 2 Chapter 12 Loop


Constructs of C Short Questions
Q 1. What is a loop?
Ans. The repeatedly execution of a statement or set of statement is called a loop. In loop the statement
or set of statements executes for a number of times or until the condition remains true. The statement
or set of statement that are executed repeatedly is called the body of the loop. Looping structures is
also called iterative or repetitive structure.

Q 2. Why loops are used?


Ans. The repeatedly execution of a statement or set of statements is called a loop. In loop the
statement or set of statement executes for a fix number of times or until the condition remains true.
Loops are used to do similar or same tasks repeatedly.
www.studysolutions.org
Q 3. What are different types of loops available in C language?
Ans. In C language there are three types of loop statements

 while loop
 do-while loop
 for loop

Q 4. What is while loop?


Ans. It is a conditional loop statement. It executes a statement or a set of statement repeatedly until
the given condition remains true.
The syntax of while loop is
while (condition)
statement;

Q 5. What is do-while loop?


Ans. It is a loop structure that is used to execute a statement or set of statement repeatedly as long as
the given condition remains true its working is similar to while loop but condition comes after the
body of the loop.
The syntax of a do...while loop in C programming language is
do {
statement(s);
} while( condition );
www.studysolutions.org

http://studysolutions.org
Engg. Ali Raza (Lecturer at Punjab Group Of Colleges Narowal)
E-mail. Armughal45@gmail.com, cell # +923476719517 Page 1
http://studysolutions.org

ICS Notes Computer Science Part 2 Chapter 12 Loop


Constructs of C Short Questions
Q 6. What is the difference between while and do-while loop?
Ans. While Loop

 Condition comes before the body of the loop.


 If condition is false at beginning body of the loop dose not execute.
 Semicolon (;) is not used at the end of the while statement.

Do-while Loop

 Condition comes after the body of the loop.


 The body of the loop is executed once even if the condition is false at the beginning.
 Semicolon (;) is given at the end of the do-while statement.
 www.studysolutions.org
Q 7. What is for loop?
Ans. 'for' is keyword of C language. 'for' statement is used as a loop statement. It is used to execute a
statement or set of statement repeatedly for a specific number of times. It is also called counter loop.
The syntax of a for loop in C programming language is
for ( init; condition; increment ) {
statement(s);
}

www.studysolutions.org
Q 8. What is nested loop?
Ans. A loop within the body of another loop is called nested loop. Any loop statement can be used
with in the body of any loop statement. For example a while can be used with in the body of for loop.
The nesting can be done up to any level. If the nesting level is increased the working of loop becomes
complex.
The syntax for a nested for loop statement in C is as follows
for ( init; condition; increment ) {

for ( init; condition; increment ) {


statement(s);
}

statement(s);
}
http://studysolutions.org
Engg. Ali Raza (Lecturer at Punjab Group Of Colleges Narowal)
E-mail. Armughal45@gmail.com, cell # +923476719517 Page 2
http://studysolutions.org

ICS Notes Computer Science Part 2 Chapter 12 Loop


Constructs of C Short Questions
Q 9. What is go to statement?
Ans. go to statement is used to transfer flow of control to a named label, It is an unconditional
statement. The label should be in same function. The syntax of goto statement is
goto label;
_________________
_________________
_________________
Label;

For more details visit

www.studysolutions.org
www.studysolutions.org

http://studysolutions.org
Engg. Ali Raza (Lecturer at Punjab Group Of Colleges Narowal)
E-mail. Armughal45@gmail.com, cell # +923476719517 Page 3

You might also like