C MCQ : if statement > Logical OR Operator inside if ….. Guess What will be the Output ?


#include<stdio.h>
void main()
{
if(1 || 0)
   printf("Dennis Ritchie is Father of C Programming");
else
   printf("Why to learn C ?");
}

Options :

  1. Why to learn C ?
  2. Compile Error
  3. Dennis Ritchie is Father of C Programming
  4. Run time Error

[toggle title="Output"]Dennis Ritchie is Father of C Programming[/toggle]

Why & How ?

  1. OR Operator is used .
  2. If any of the case is True then If block will be executed.
  3. If it founds First Operand as non-zero number then it declare whole statement as TRUE statement