C Decision making & Loops-1
1. Choose a right C Statement.
a) Loops or Repetition block executes a group of statements repeatedly
b) Loop is usually executed as long as a condition is met
c) Loops usually take advantage of Loop Counter
d) All the above
Answer: D
No explanation is given for this question.
2. Loops in C Language are implemented using?
a) While Block
b) For Block
c) Do While Block
d) All the above
Answer: D
No explanation is given for this question.
3. Which loop is faster in C Language, for, while or Do While?
a) for
b) while
c) do while
d) All work at same speed
Answer: D
The speed of loops depends upon the compiler and hardware.
4. If block always need to be assoicated with a else block?
a) True
b) False
Answer: B
An if statement looks at any and every thing in the parentheses and if true, executes block of code that follows. If you require code to run only when the statement returns true (and do nothing else if false) then an else statement is not needed.
5. Which of the following is binary operator?
a) &&
b) ||
c) both i & ii
d) !
Answer: D
! is a binary operator.
6. The conditional operator are also known as
a) Relational operator
b) Binary operator
c) Ternary operator
d) Arithematic operator
Answer: C
No explanation is given for this question.
7. What will be the value of y if x = 8?
y = (x > 6 ? 4 : 6);
a) Compilation Error
b) 0
c) 4
d) 6
Answer: C
x is greater than 6 i.e. the execute value is 4. Therefore, value of y is 4.
8. Which of the following operator reverses the result of expression it operators on
a) !
b) ||
c) &&
d) All of the above
Answer: A
No explanation is given for this question.
9. If you have to make decision based on multiple choices, which of the following is best suited?
a) if
b) if-else
c) if-else-if
d) All of the above
Answer: C
No explanation is given for this question.
10. The continue statment cannot be used with ________
a) for
b) while
c) do while
d) switch
Answer: D
continue is used to skip the statments and can not be used with switch case.