Output of C Program | Set 17 Last Updated : 31 Jul, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report 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-referenced, hence it yields type of the object. In the present case, it is an array of array of integers. So, it prints R*C*sizeof(int). Thanks to Venki for suggesting this solution. Question 2 C #include<stdio.h> #define f(g,g2) g##g2 int main() { int var12 = 100; printf("%d", f(var,12)); getchar(); return 0; } Output: 100 The operator ## is called "Token-Pasting" or "Merge" Operator. It merges two tokens into one token. So, after preprocessing, the main function becomes as follows, and prints 100. C int main() { int var12 = 100; printf("%d", var12); getchar(); return 0; } Question 3 C #include<stdio.h> int main() { unsigned int x = -1; int y = ~0; if(x == y) printf("same"); else printf("not same"); printf("\n x is %u, y is %u", x, y); getchar(); return 0; } Output: "same x is MAXUINT, y is MAXUINT" Where MAXUINT is the maximum possible value for an unsigned integer. -1 and ~0 essentially have same bit pattern, hence x and y must be same. In the comparison, y is promoted to unsigned and compared against x. The result is "same". However, when interpreted as signed and unsigned their numerical values will differ. x is MAXUNIT and y is -1. Since we have %u for y also, the output will be MAXUNIT and MAXUNIT. Thanks to Venki for explanation. 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 21 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 2 min read Output of C Program | Set 18 Predict the output of following C programs.Question 1 C #include<stdio.h> int fun() { static int num = 40; return num--; } int main() { for(fun(); fun(); fun()) { printf("%d ", fun()); } getchar(); return 0; } Output: 38 35 32 29 26 23 20 17 14 11 8 5 2Since num is static in fun(), t 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 Programs | Set 7 Predict the output of below programsQuestion 1 c int main() { int i = 0; while (i <= 4) { printf("%d", i); if (i > 3) goto inside_foo; i++; } getchar(); return 0; } void foo() { inside_foo: printf("PP"); } Output: Compiler error: Label "inside_foo" used but not defined.Expl 2 min read Like