Output of C Programs | Set 16 Last Updated : 31 Jul, 2018 Comments Improve Suggest changes 25 Likes Like Report Predict the output of below C programs. Question 1 C #include <stdio.h> char* fun() { return "awake"; } int main() { printf("%s",fun()+ printf("I see you")); getchar(); return 0; } Output: Some string starting with "I see you" Explanation: (Thanks to Venki for suggesting this solution) The function fun() returns pointer to char. Apart from printing string "I see you", printf() function returns number of characters it printed(i.e. 9). The expression [fun()+ printf("I see you")] can be boiled down to ["awake" + 9] which is nothing but base address of string literal "awake" displaced by 9 characters. Hence, the expression ["awake" + 9] returns junk data when printed via %s specifier till it finds '\0'. Question 2 C #include <stdio.h> int main() { unsigned i ; for( i = 0 ; i < 4 ; ++i ) { fprintf( stdout , "i = %d\n" , ("11213141") ) ; } getchar(); return 0 ; } Output: Prints different output on different machines. Explanation: (Thanks to Venki for suggesting this solution) The format specifier is %d, converts the base address of string "11213141" as an integer. The base address of string depends on memory allocation by the compiler. The for loop prints same address four times. Try to use C++ streams, you will see power of type system. Please write comments if you find any of the answers/explanations incorrect, or you want to share more information about the topics discussed above Comment K kartik Follow 25 Improve K kartik Follow 25 Improve Article Tags : C Language C-Output Explore C BasicsC Language Introduction6 min readIdentifiers in C3 min readKeywords in C2 min readVariables in C4 min readData Types in C3 min readOperators in C8 min readDecision Making in C (if , if..else, Nested if, if-else-if )7 min readLoops in C6 min readFunctions in C5 min readArrays & StringsArrays in C4 min readStrings in C5 min readPointers and StructuresPointers in C7 min readFunction Pointer in C6 min readUnions in C3 min readEnumeration (or enum) in C5 min readStructure Member Alignment, Padding and Data Packing8 min readMemory ManagementMemory Layout of C Programs5 min readDynamic Memory Allocation in C7 min readWhat is Memory Leak? How can we avoid?2 min readFile & Error HandlingFile Handling in C11 min readRead/Write Structure From/to a File in C3 min readError Handling in C8 min readUsing goto for Exception Handling in C4 min readError Handling During File Operations in C5 min readAdvanced ConceptsVariadic Functions in C5 min readSignals in C language5 min readSocket Programming in C8 min read_Generics Keyword in C3 min readMultithreading in C9 min read Like