Output of C Program | Set 21 Last Updated : 21 Oct, 2022 Comments Improve Suggest changes Like Article 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 More infoAdvertise with us Next Article Output of C Program | Set 27 K kartik Follow Improve Article Tags : C Language C-Output Similar Reads Output of C Programs | Set 1 Predict the output of below programs. Question 1c#include<stdio.h> int main() { int n; for(n = 7; n!=0; n--) printf("n = %d", n--); getchar(); return 0; }Output: Above program goes in infinite loop because n is never zero when loop condition (n != 0) is checked.Question 2c #include<stdio.h 2 min read Output of C Program | Set 27 Predict the output of following C programs. Question 1 C #include <stdio.h> int main(void) { int i; int power_of_ten[5] = { 00001, 00010, 00100, 01000, 10000, }; for (i = 0; i < 5; ++i) printf("%d ", power_of_ten[i]); printf("\n"); return 0; } In the above example, we ha 3 min read Output of C Program | Set 17 Predict the output of following C programs. Question 1 C #include<stdio.h> #define R 10 #define C 20 int main() { int (*p)[R][C]; printf("%d", sizeof(*p)); getchar(); return 0; } Output: 10*20*sizeof(int) which is "800" for compilers with integer size as 4 bytes. The pointer p is de- 2 min read Output of C Program | Set 19 Predict the outputs of following program. Difficulty Level: Rookie Question 1 C #include <stdio.h> int main() { int a = 10, b = 20, c = 30; if (c > b > a) { printf("TRUE"); } else { printf("FALSE"); } getchar(); return 0; } Output: FALSE Let us consider the condition 1 min read Output of C Program | Set 29 Question 1 How many times main() will get called? C main() { printf("\n main Called Again"); main(); } Answer : Infinite loop Description : There is no condition in the main() to stop the recursive calling of the main() hence it will be called infinite no of times. Question 2 Guess the out 6 min read Output of C Program | Set 20 Predict the outputs of following C programs. Question 1 C int main() { int x = 10; static int y = x; if(x == y) printf("Equal"); else if(x > y) printf("Greater"); else printf("Less"); getchar(); return 0; } Output: Compiler Error In C, static variables can only be in 2 min read Like