Output of C Programs | Set 10 Last Updated : 28 Oct, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report Predict the output of the below programs. Difficulty Level: RookieQuestion 1 c #include<stdio.h> int main() { typedef int i; i a = 0; printf("%d", a); getchar(); return 0; } Output: 0 There is no problem with the program. It simply creates a user defined type i and creates a variable a of type i.Question 2 c #include<stdio.h> int main() { typedef int *i; int j = 10; i *a = &j; printf("%d", **a); getchar(); return 0; } Output: Compiler Error -> Initialization with incompatible pointer type. The line typedef int *i makes i as type int *. So, the declaration of a means a is pointer to a pointer. The Error message may be different on different compilers. One possible correct solution of this code is in Question 4. Also now try this: C #include <stdio.h> int main() { typedef int *i; int j = 10; int *p = &j; i *a = &p; printf("%d", **a); getchar(); return 0; } Question 3 c #include<stdio.h> int main() { typedef static int *i; int j; i a = &j; printf("%d", *a); getchar(); return 0; } Output: Compiler Error -> Multiple Storage classes for a. In C, typedef is considered as a storage class. The Error message may be different on different compilers. Question 4 c #include<stdio.h> int main() { typedef int *i; int j = 10; i a = &j; printf("%d", *a); getchar(); return 0; } Output: 10 Please write comments if you find any of the answers/explanations incorrect, or you want to share more information about the topics discussed above. References: http://www.itee.uq.edu.au/~comp2303/Leslie_C_ref/C/SYNTAX/typedef.html http://publib.boulder.ibm.com/infocenter/macxhelp/v6v81/index.jsp?topic=/com.ibm.vacpp6m.doc/language/ref/clrc03sc03.htm http://msdn.microsoft.com/en-us/library/4x7sfztk.aspx Comment More infoAdvertise with us Next Article Output of C Programs | Set 14 K kartik Follow Improve Article Tags : C Language 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 Programs | Set 16 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 sug 2 min read Output of C Programs | Set 13 Difficulty Level: Rookie Question 1 Predict the output of below program. C int main() { char arr[] = "geeksforgeeks"; printf("%d", sizeof(arr)); getchar(); return 0; } Output: 14 The string âgeeksforgeeksâ has 13 characters, but the size is 14 because compiler includes a single ' 2 min read Output of C Programs | Set 14 Predict the output of below C programs. Question 1 C #include<stdio.h> int main() { int a; char *x; x = (char *) &a; a = 512; x[0] = 1; x[1] = 2; printf("%d\n",a); getchar(); return 0; } Answer: The output is dependent on endianness of a machine. Output is 513 in a little endian 2 min read Output of C programs | Set 8 Predict the output of below C programs. Question 1: c #include<stdio.h> int main() { int x = 5, p = 10; printf("%*d", x, p); getchar(); return 0; } Output: 10 Explanation: Please see standard printf function definition int printf ( const char * format, ... ); format: String that cont 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 Like