Vous êtes sur la page 1sur 2

Unit-4-programming in c++

FLOW OF CONTROL
1 What is NULL statement(empty statement)? What is the use it?
; // it is null statement

It is useful in those instances where syntax of the language requires the presence of a statement but
where the logic of the program does not.

2 Define compound statement ( block)


3 What are the types of looping constructs?
4 Comparison between ‘if’ and ‘ ?: ’

If ?:
Code is not compact compared to ?: Code is compact
Code is obvious Code is less obvious compared to if
It can have multiple statements, multiple Only single value can be assigned
assignments and expressions in its body.
Even when it is used in nested form, it is easy to When it is used in nested form, it is difficult to
understand understand

5 Comparison between ‘ switch’ and ‘if-else ’ statement

Switch If-else
work only with equality comparison Work with relational and logical comparison
Work only with integer and character constant Work with all type of constants
Used only for one variable comparison Used for one or more variable comparison
More efficient than if-else Less efficient than switch

6 What is ‘fall through’ ?

Inside ‘switch’ statement, if a ‘case’ statement does not include ‘break’ statement , then control
continues to the next ‘case’ statements until either a break is encountered or end of switch is reached.
This situation is called ‘fall through’.

7 What is the significance of default clause in a switch statement ?

‘default’ clause gets executed when the value of the expression is not matching with the constants
specified in the ‘case’ statement.

8 What is entry controlled loop ? Write example.


9 What is exit controlled loop ? Write example.
10 What are the ‘jump’ statement? Explain.
11 Compare between ‘break’ and ‘continue’ with the help of example.
Standard library function
Identify the header file needed for the following functions.

gets(),puts() -> stdio.h


strcpy(), strcat(), strlen(), strcmp(), strcmpi() –string.h
get(),getline(),write(),read() -> iostream.h
setw(),setprecision() - iomanip.h
rand(), srand() , random(), randomize() - stdlib.h
exit() –process.h
clrscr(), getch() –conio.h

*****************************

Vous aimerez peut-être aussi