C Programming Quiz : Conditional Operator
C Programming Quiz : Conditional Operators
1. What are C Programming conditional statement?
- A) if statement
- B) else statement
- C) else if statement
- D) All of the above
Answer is D)
Description:
if, else, else if and :,? (Ternary Question Mark) are C Programming conditional statement.
2. Choose a syntax for C Ternary Operator from the list.
- A) condition : expression1 ? expression2
- B) condition ? expression1 : expression2
- C) condition ? expression1 < expression2
- D) condition < expression1 ? expression2
Answer is B)
Description:
If the condition is true, expression 1 is evaluated. If the condition is false, expression 2 is evaluated.
3. What is the output of the C statement?
- A) 4
- B) 6
- C) 2
- D) 3
Answer is D)
Description:
5<2 3="" a.="" and="" assigned="" be="" false.="" is="" p="" picked="" so="" the="" to="" variable="" will="">
2>
4. What is the output of C Program?
- A) Compile Error
- B) 40
- C) 04
- D) 41
Answer is D)
Description:
a = printf("4");
First printf prints 4. printf() returns 1. Now the variable a=1; So 1 is printed next.
5. Choose a statement to use C If Else statement.
- A) else if is compulsory to use with if statement.
- B) else is compulsory to use with if statement.
- C) else or else if is optional with if statement.
- D) None of the above.
Answer is C)
Description:
else or else if is optional with if statement.
6. What is the Priority of C Logical Operators? NOT (!), AND (&&) and OR (||)
- A) NOT (!) > AND (&&) > OR (||)
- B) NOT (!) > AND (&&) = OR (||)
- C) AND (&&) > OR (||) > NOT (!)
- D) AND (&&) = OR (||) > NOT (!)
Answer is A)
Description:
Logical NOT Operator in C has the highest priority.
7. What is the output of the C Program?
- A) CAT DOG FOX
- B) Compiler error
- C) FOX
- D) CAT DOG
Answer is B)
Description:
You can not put more than 1 statement inside expression1 or expression2 inside Ternary Operator.
8. What is the output of the following code?
- A) Error
- B) True
- C) False
- D) None of the these.
Answer is B)
Description:
Relational operator have more priority than logical operator. So,
(5 && (5 == 5))
Or, (5 && 1)
Or, 1
Hence condition becomes true and printf(“true”); executed.
9. Which operators are known as Ternary Operator?
- A) ::
- B) :=:
- C) :,?
- D) ;:?
Answer is C)
Description:
:,? operators are known as Ternary Operator?
10. An operator used to check a condition and select a value depending on the value of the condition is called
- A) Bitwise operator
- B) Decrement operator
- C) Logical operator
- D) Conditional or Ternary operator
Answer is D)
Description:
An operator used to check a condition and select a value depending on the value of the condition is called Conditional or Ternary operator.
Submit your Quiz Question
Submit your quiz question to us, We will feature your quiz question in our blog with your credits.
Post a Comment