Q. What is the output of the following code?

Code:
int a = 10;
if (a = 0)
    printf("Zero");
else
    printf("Non-zero");
  • (A) Zero
  • (B) Non-zero
  • (C) Compile error
  • (D) Runtime error
πŸ’¬ Discuss
βœ… Correct Answer: (B) Non-zero
Explanation: The assignment 'a = 0' evaluates to false, so the else block runs and prints 'Non-zero'.
Explanation by: Mr. Dubey
The assignment 'a = 0' evaluates to false, so the else block runs and prints 'Non-zero'.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
85
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
84%
Success Rate