Must Read Tip To Solve Following Problem :

  1. The Main Always returns positive Value.
  2. Inside C Program Function is nothing but set of instructions combined together in a single block.
  3. Function Block may have certain starting address.
  4. This Address gets printed when we try to print function name inside printf statement.

Example :

printf("%d", main);

Output : (it may differ)

657

Now try to Guess the Output of the Following Code Snippet , What is output of the following program ?

#include<stdio.h>
int main()
{
int c = 5;
printf("%d", main || c);
return(0);
}

Output :

1

Explanation :

  1. main will return positive non-zero number.
  2. c is non-zero number.
  3. “OR”ing of two non zero numbers is “TRUE” i.e 1 in C Programming.
  4. If c = 0 then also Program will print 1 as output.
[/toggle]

This C Programming Interview Questions : Asked in -

  1. Infosys Interview 2010
  2. Accenture Pune 2011