Output of C Program | Set 22 Last Updated : 18 Aug, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report Predict the output of following C programs.Question 1: C #include<stdio.h> int main() { enum channel {star, sony, zee}; enum symbol {hash, star}; int i = 0; for(i = star; i <= zee; i++) { printf("%d ", i); } return 0; } Output: compiler error: redeclaration of enumerator 'star' In the above program, enumeration constant 'star' appears two times in main() which causes the error. An enumeration constant must be unique within the scope in which it is defined. The following program works fine and prints 0 1 2 as the enumeration constants automatically get the values starting from 0. C #include<stdio.h> int main() { enum channel {star, sony, zee}; int i = 0; for(i = star; i <= zee; i++) { printf("%d ", i); } return 0; } Output: 0 1 2 Question 2: C #include<stdio.h> int main() { int i, j; int p = 0, q = 2; for(i = 0, j = 0; i < p, j < q; i++, j++) { printf("GeeksforGeeks\n"); } return 0; } Output: GeeksforGeeks GeeksforGeeks Following is the main expression to consider in the above program. C i < p, j < q When two expressions are separated by comma operator, the first expression (i < p) is executed first. Result of the first expression is ignored. Then the second expression (j < q) is executed and the result of this second expression is the final result of the complete expression (i < p, j < q). The value of expression 'j < q' is true for two iterations, so we get "GeeksforGeeks" two times on the screen. See this for more details.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 Programs | Set 2 K kartik Follow Improve Article Tags : C Language C-Output Similar Reads 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 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 Programs | Set 2 Predict the output of below programs. Question 1 c #include<stdio.h> char *getString() { char str[] = "Will I be printed?"; return str; } int main() { printf("%s", getString()); getchar(); } Output: Some garbage value The above program doesn't work because array variables a 2 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 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 Output of C Program | Set 24 Predict the output of following C programs:Difficulty Level: Rookie Question 1 C #include<stdio.h> int main() { int arr[] = {10, 20, 30, 40, 50, 60}; int *ptr1 = arr; int *ptr2 = arr + 5; printf ("ptr2 - ptr1 = %d\n", ptr2 - ptr1); printf ("(char*)ptr2 - (char*) ptr1 = %d", 3 min read Like