Monday, September 6, 2010

Objective Type Questions on Loop

1. The general form of the conditional expression is
a. expression 1 ? expression 2 :expression 3
b. expression 2 ? expression 3 ?expression 1
c. expression 3 ? expression 2 :expression 1
d. expression 1 ? expression 2 ?expression 3

Ans: a

2. Any program in C, has access to three standard files
a. standrad input file, standard output file, standard error file
b. stdin, stdout, stderr
c. keyboard, screen, screen
d. all of the above
e. none of the above

Ans: d

3. In a simple 'if' statement with no 'else', what happens if the condition following the 'if' is false ?
a. The program searches for the last else in the program
b. Nothing
c. Control 'falls through' to the statement folowing 'if'
d. The body of the statement is executed

Ans: c

4. A while loop is more appropriate than a for loop when
a. the body of the loop will be executed at last once
b. the terminating condition occurs unexpectedly
c. the program will be executed at least once
d. the number of times the loop will be executed is known before the loop is executed
e. none of the above

Ans: b

5. The comma operator(,) is used to
a. permit two different expressions to appear in situations where only once expression would ordinarily be used
b. terminate loops or to exit from switch
c. alter the normal sequence of program execution by transferring control to some other part of the program
d. carry out a logical test and then take one of two possible actions, depending upon the outcome of the test

Ans: a

No comments: