Tutorial 2 What Is The Output of The Below Program?
The output is: 0 2 7 12 17 22. The switch statement causes i to increment by different amounts on each iteration - 5 on cases 0 and 5, 2 on case 1, and 4 in the default
Download as DOC, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
79 views
Tutorial 2 What Is The Output of The Below Program?
The output is: 0 2 7 12 17 22. The switch statement causes i to increment by different amounts on each iteration - 5 on cases 0 and 5, 2 on case 1, and 4 in the default
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2
Tutorial 2
1 What is the output of the below program? 2 #include <stdio.h>
#include <stdio.h> #define EVEN 0 int main() #define ODD 1 { int main() int i = 0; { switch (i) int i = 3; { switch (i & 1) case '0': { printf("Geeks"); case EVEN: break; printf("Even"); case '1': printf("Quiz"); break; break; case ODD: printf("Odd"); default: break; printf("GeeksQuiz"); default: } printf("Default"); return 0; } } return 0; }
3 Predict the output of above program? 4 #include<stdio.h>
int main() #include <stdio.h> { int main() int n; { for (n = 9; n!=0; n--) int i; printf("n = %d", n--); if (printf("0")) return 0; i = 3; } else What is the output? i = 5; printf("%d", i); return 0; } 5 Output? 6 # include <stdio.h> #include <stdio.h> int main() int main() { { int i = 0; int c = 5, no = 10; for (i=0; i<20; i++) do { { no /= c; switch(i) } while(c--); { case 0: printf ("%d\n", no); i += 5; case 1: return 0; } i += 2; case 5: i += 5; default: i += 4; break; } printf("%d ", i); } return 0; } 7 #include <stdio.h> 8 #include <stdio.h> int main() int main() { { int i = 3; int x = 3; while (i--) if (x == 2); x = 0; { if (x == 3) x++; int i = 100; else x += 2; i--; printf("%d ", i); printf("x = %d", x); } return 0; return 0; } }
9 Predict output of following program 10
int main() { int i; int arr[5] = {1}; for (i = 0; i < 5; i++) printf("%d ", arr[i]); return 0; } 11 12 13 14