Must Read Tip To Solve Following Problem :
- The Main Always returns positive Value.
- Inside C Program Function is nothing but set of instructions combined together in a single block.
- Function Block may have certain starting address.
- 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 :
- main will return positive non-zero number.
- c is non-zero number.
- “OR”ing of two non zero numbers is “TRUE” i.e 1 in C Programming.
- If c = 0 then also Program will print 1 as output.
This C Programming Interview Questions : Asked in -
- Infosys Interview 2010
- Accenture Pune 2011