Output of C Programs | Set 7 Last Updated : 19 Jan, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report 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.Explanation: Scope of a label is within a function. We cannot goto a label from other function.Question 2 c #define a 10 int main() { #define a 50 printf("%d",a); getchar(); return 0; } Output: 50Preprocessor doesn't give any error if we redefine a preprocessor directive. It may give warning though. Preprocessor takes the most recent value before use of and put it in place of a.Now try following c #define a 10 int main() { printf("%d ",a); #define a 50 printf("%d ",a); getchar(); return 0; } Question 3 c int main() { char str[] = "geeksforgeeks"; char *s1 = str, *s2 = str; int i; for(i = 0; i < 7; i++) { printf(" %c ", *str); ++s1; } for(i = 0; i < 6; i++) { printf(" %c ", *s2); ++s2; } getchar(); return 0; } Output g g g g g g g g e e k s fExplanation Both s1 and s2 are initialized to str. In first loop str is being printed and s1 is being incremented, so first loop will print only g. In second loop s2 is incremented and s2 is printed so second loop will print "g e e k s f "Question 4 c int main() { char str[] = "geeksforgeeks"; int i; for(i=0; str[i]; i++) printf("\n%c%c%c%c", str[i], *(str+i), *(i+str), i[str]); getchar(); return 0; } Output: gggg eeee eeee kkkk ssss ffff oooo rrrr gggg eeee eeee kkkk ssssExplanation: Following are different ways of indexing both array and string.arr[i] *(arr + i) *(i + arr) i[arr]So all of them print same character.Question 5 c int main() { char *p; printf("%d %d ", sizeof(*p), sizeof(p)); getchar(); return 0; } Output: Compiler dependent. I got output as "1 4"Explanation: Output of the above program depends on compiler. sizeof(*p) gives size of character. If characters are stored as 1 byte then sizeof(*p) gives 1. sizeof(p) gives the size of pointer variable. If pointer variables are stored as 4 bytes then it gives 4. Comment More infoAdvertise with us Next Article Output of C Programs | Set 6 K kartik Follow Improve Article Tags : C Language C-Output Similar Reads Output of C programs | Set 37 1.) What will be the output of the following code? C #include <stdio.h> int main(void) { int y, z; int x = scanf("%d %d", &y, &z); printf("%d", x); return 0; } Input: 12 10 a)12 b)2 c)Syntax Error d)10 Answer : b Explanation: scanf() returns the number of variables 3 min read 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 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 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 6 Predict the output of below programs Question 1 c int main() { unsigned int i=65000; while ( i++ != 0 ); printf("%d",i); return 0; } Output: 1 Explanation: It should be noticed that there's a semi-colon in the body of while loop. So even though, nothing is done as part of while body, the c 4 min read Output of C Programs | Set 5 Predict the output of below programs Question 1 c int main() { while(1){ if(printf("%d",printf("%d"))) break; else continue; } return 0; } Output: Can't be predictedExplanation: The condition in while loop is 1 so at first shot it looks infinite loop. Then there are break and con 5 min read Like