Output of the C Program | Dereference and Reference Last Updated : 16 Apr, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The operator * is used for dereferencing and the operator & is used to get the address (can be called reference in general sense). These operators cancel effect of each other when used one after another. We can apply them alternatively any no. of times.Based on above information, predict the output of below program: C #include <stdio.h> int main() { char *ptr = "geeksforgeeks"; printf("%c\n", *&*&*ptr); getchar(); return 0; } Outputg Explanation: The expression *&*&*ptr dereferences ptr to get the character 'g' from the string "geeksforgeeks". First, ptr is dereferenced to get 'g', then address is obtained returning ptr. Again, it is dereferenced returning 'g' and then address is determined returing ptr. Finally, it is dereferenced to obtain 'g'. Therefore, the program prints 'g'.Now try predicting the output of the below: C #include <stdio.h> int main() { char *ptr = "geeksforgeeks"; printf("%s\n", *&*&ptr); getchar(); return 0; } Outputgeeksforgeeks Explanation: The expression *&*&ptr is equivalent to just ptr in this code. It first dereferences ptr to get the string "geeksforgeeks", then takes its address and dereferences it again, ultimately returning the original address stored in ptr. Therefore, the program prints "geeksforgeeks". Comment More infoAdvertise with us Next Article Output of C programs | Set 46 K kartik Follow Improve Article Tags : C Language Program Output C-Output C-Pointers Similar Reads Output of C Programs | Set 3 Predict the output of the below program. Question 1 c #include <stdio.h> int main() { printf("%p", main); getchar(); return 0; } Output: Address of function main. Explanation: Name of the function is actually a pointer variable to the function and prints the address of the function. 3 min read Output of C programs | Set 46 QUE.1 What would be output following C program? C #include <stdio.h> int main() { char* str = "IncludeHelp"; printf("%c\n", *&*str); return 0; } OPTION a) Error b) IncludeHelp c) I d)*I Answer: c Explanation : & is a reference operator, * is de-reference operator. W 3 min read Output of C Programs | Set 12 Predict the output of below programs. Question 1 c int fun(char *str1) { char *str2 = str1; while(*++str1); return (str1-str2); } int main() { char *str = "geeksforgeeks"; printf("%d", fun(str)); getchar(); return 0; } Output: 13 Inside fun(), pointer str2 is initialized as str1 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 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 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