Question 1
#include <stdio.h> int main() { int i = 1024; for (; i; i >>= 1) printf("GeeksQuiz"); return 0; }
Question 2
#include <stdio.h> #define PRINT(i, limit) do \\ { \\ if (i++ < limit) \\ { \\ printf("GeeksQuiz\\n"); \\ continue; \\ } \\ }while(0); int main() { int i = 0; PRINT(i, 3); return 0; }
How many times GeeksQuiz is printed in the above program ?
1
3
4
Compile-time error
Question 3
What is the output of the below program?
#include <stdio.h> int main() { int i = 2; switch (i) { case 0: printf("Geeks"); break; case 1: printf("Quiz"); break; default: printf("GeeksQuiz"); } return 0; }
Geeks
Quiz
GeeksQuiz
Compile-time error
Question 4
#include <stdio.h> int main() { int i = 3; switch (i) { case 1: printf("Geeks"); break; case 1+2: printf("Quiz"); break; default: printf("GeeksQuiz"); } return 0; }
What is the output of the above program?
Geeks
Quiz
GeeksQuiz
Compile-time error
Question 5
Predict the output of the below program:
#include <stdio.h> #define EVEN 0 #define ODD 1 int main() { int i = 3; switch (i % 2) { case EVEN: printf("Even"); break; case ODD: printf("Odd"); break; default: printf("Default"); } return 0; }
Even
Odd
Default
Compile-time error
Question 6
#include <stdio.h> int main() { int i; if (printf("0")) i = 3; else i = 5; printf("%d", i); return 0; }
Predict the output of above program?
3
5
03
05
Question 7
#include <stdio.h> int i; int main() { if (i) { // Do nothing } else { printf("Else"); } return 0; }
What is correct about the above program?
if block is executed.
else block is executed.
It is unpredictable as i is not initialized.
Error: misplaced else
Question 8
#include<stdio.h> int main() { int n; for (n = 9; n!=0; n--) printf("n = %d", n--); return 0; }
Question 9
#include <stdio.h> int main() { int c = 5, no = 10; do { no /= c; } while(c--); printf ("%d\\n", no); return 0; }
Question 10
# include <stdio.h> int main() { int i = 0; for (i=0; i<20; i++) { switch(i) { case 0: i += 5; case 1: i += 2; case 5: i += 5; default: i += 4; break; } printf("%d ", i); } return 0; }
5 10 15 20
7 12 17 22
16 21
Compiler Error
There are 45 questions to complete.