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

Answers

5.5 Short Answer Questions and


ot controlstatenments?
1. What is the use of
Ans, The control used to make a dociston.
are
statehents
list ot statements.
C.
2. Mention all the controllstateuents available in
S. . ifelse, ne'sted it. elseil,d,dot switeh ad goto statemens.
3. What is the purpose of it statement?
ne t is aone wav branhing statement. It is Used to cary some oerations it the omte
is onl true,
general syntax of if?
Controd Sructures
A Writethe
Ans. il
(condition)
statement;
of if-else
statement?
Whatisthe purpose
5.
if-else statement is atwo-way
Ans. The
branching statement. If the
statementsinthe if block are executed; otherwise the else block arecondition
executed.
is true, he tre
Write the general syntax of if-else?
6.
Ans.if(condition)
statement 1;

else
statement 2;

7 What do you mean by nested if?


LCocosing if within if is called nested if. The nested if helps where two (or)
need to be tested. more condis
What is else-if ladder?
Ans. The else-if ladder is a multi-way decision maker which
consists of two (or) more else-if iro
which only one block is executed.
9. What is the purpose of switch construct?
Ans. switch construct provides a multiway branching which allows the user to
select any one of the
alternatives depending on the value of an expression.
10. How switch is differ from if?
AS. r is one-way branching statement and switch is multi-way branching statement
1. What is the use of default in
Ans. Default is
switch?
optional; the statements of the default case are executed when none of the cases ar
satisfied.
12. Whattis
i the use of break in
switch?
Ans. The
break is used to terminate the switch construct.
13. What are the
values the have?
case label can
Ans. integer (or) character.
14. Is
Ans. Yes. default can be placed anywhere in switch?
15. Can we
Ans. Yes. have a switch inside a case label?
5.58
Programming in C

16. What is a loop?


Ans. Aloop is a Construct that executes the statements repeatedly for a
certain number of
as long as the condition is
true. times (ox,
17. What are the three looping
Ans.
constructs available in C?
1. while loop 2. do.. while loop 3. for loop.
18. Which looping
construct is called pre-test loop?
Ans. 1. while
2. for
19. Write the general
syntax of while loop.
Ans. while(condition)

statement 1;
statement 2;
20. Write the general
Ans. do
syntax of do.. while?

statement 1;
statement 2;
}while (condition);
21. Write the general
syntax of for loop?
Ans. for(expr1; expr2; expr3)

statement 1;
statement 2:

22. What is the difference between


while and do., while?
Ans. In while,the condition is tested before. In do.
body of the loop for first time. while, the condition is executing
tested after
23. What is the use of break in loops?
Ans. break is used in loop to terminate the loop execution.
24. What is the use of continue in loops?
Ans. continue is used to take the control to the beginning of loop for next iteration.

25. What is an infinite loop?


which executes the body of theloop for infinite number of times.
Ans. Aloop
26. Howto terminatethe infinite loop? Control Structures 5
The infinite loop
can be terminated by
Ans.
using break (or) return in
Which looping constructtiis called the body of the
27.
Ans. do. while
"post-test" loop? loop.

28. Is it possible to do multiple


Ans. Yes.
initializations in for loop?
90 lsit Dossible to omit all the
expressions in the for Joon?
Ans. Yes.

30. What is Nested loop?


Ans. Enclosing a loop within another loop is called
nested loop.
31. What is the use of goto
statement?
Ans. The goto statement allows the programmer to branch
another. unconditionally from one point to

32. Write the general syntax of goto statement.


Ans.

goto label;

label:

33. When to use do.. whileloop? at least once


execute the loop body
Ans. do.. while should be preferred when we are sure to

34. wil! be e\uted


When to use for loop?
Ans, The for loop is used when we knowin advance how
many timestheloop

5.6 Exercise
1.
What are control statements? statements?
2. What are different forms ofit statement
3. Explain any two forms of'if' statements. if
numbers using stitement
4. oftwo statements. it-elsc'
5. Write a program to find largestnested-if-else
oddor
evenusing

6.
Give the syntax of if-else, whether anuumber
and is

Write a Program to check

You might also like