Output of C Program | Set 21 Last Updated : 23 Jul, 2025 Comments Improve Suggest changes 45 Likes Like Report Predict the output of following C programs. Question 1 C #include<stdio.h> #define fun (x) (x)*10 int main() { int t = fun(5); int i; for(i = 0; i < t; i++) printf("GeeksforGeeks\n"); return 0; } Output: Compiler Error There is an extra space in macro declaration which causes fun to be replaced by (x). If we remove the extra space then program works fine and prints "GeeksforGeeks" 50 times. Following is the working program. C #include<stdio.h> #define fun(x) (x)*10 int main() { int t = fun(5); int i; for(i = 0; i < t; i++) printf("GeeksforGeeks\n"); return 0; } Be careful when dealing with macros. Extra spaces may lead to problems. Question 2 C #include<stdio.h> int main() { int i = 20,j; i = (printf("Hello"), printf(" All Geeks ")); printf("%d", i); return 0; } Output: Hello All Geeks 11 The printf() function returns the number of characters it has successfully printed. The comma operator evaluates it operands from left to right and returns the value returned by the rightmost expression (See this for more details). First printf("Hello") executes and prints "Hello", the printf(" All Geeks ") executes and prints " All Geeks ". This printf statement returns 11 which is assigned to i. 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 45 Improve K kartik Follow 45 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