Question 1 of 25
Hints left: 3
Q1
What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input) #include <stdio.h> void main() { double ch; printf("enter a value between 1 to 2:"); scanf("%lf", &ch); switch (ch) { case 1: printf("1"); break; case 2: printf("2"); break; } }
Q2
What will be the output of the following C code? #include <stdio.h> void main() { int i = 5, k; if (i == 0) goto label; label: printf("%d", i); printf("Hey"); }
Q3
What is an example of iteration in C?
Q4
Which of the following is an invalid if-else statement?
Q5
What will be the output of the following C code? #include <stdio.h> int main() { int i = 0, j = 0; while (i < 2) { l1 : i++; while (j < 3) { printf("Loop\n"); goto l1; } } }
Q6
What will be the output of the following C code? #include <stdio.h> void main() { int i = 0; for (i = 0;i < 5; i++) if (i < 4) { printf("Hello"); break; } }
Q7
Which datatype can accept the switch statement?
Q8
Which for loop has range of similar indexes of 'i' used in for (i = 0;i < n; i++)?
Q9
What will be the output of the following C code? #include <stdio.h> int main() { int i = 0; char c = 'a'; while (i < 2) { i++; switch (c) { case 'a': printf("%c ", c); break; break; } } printf("after loop\n"); }
Q10
What will be the output of the following C code? #include <stdio.h> int x; void main() { if (x) printf("hi"); else printf("how are u"); }
Q11
What will be the output of the following C code? #include <stdio.h> int main() { short i; for (i = 1; i >= 0; i++) printf("%d\n", i); }
Q12
What will be the correct syntax for running two variable for loop simultaneously?
Q13
What will be the output of the following C code? #include <stdio.h> int main() { printf("%d ", 1); goto l1; printf("%d ", 2); } void foo() { l1: printf("3 ", 3); }
Q14
What will be the output of the following C code? #include <stdio.h> void main() { int k = 0; for (k) printf("Hello"); }
Q15
What will be the output of the following C code? (Assuming that we have entered the value 2 in the standard input) #include <stdio.h> void main() { int ch; printf("enter a value between 1 to 2:"); scanf("%d", &ch); switch (ch) { case 1: printf("1\n"); break; printf("hi"); default: printf("2\n"); } }
Q16
What will be the output of the following C code? #include <stdio.h> int main() { do printf("In while loop "); while (0); printf("After loop\n"); }
Q17
What will be the output of the following C code? #include <stdio.h> void main() { char *str = ""; do { printf("hello"); } while (str); }
Q18
What will be the output of the following C code? #include <stdio.h> int main() { while () printf("In while loop "); printf("After loop\n"); }
Q19
What will be the output of the following C code? #include <stdio.h> int main() { float f = 1; switch (f) { case 1.0: printf("yes\n"); break; default: printf("default\n"); } }
Q20
What will be the output of the following C code? #include <stdio.h> int main() { int i = 0, j = 0; while (l1: i < 2) { i++; while (j < 3) { printf("loop\n"); goto l1; } } }
Q21
Which loop is most suitable to first perform the operation and then test the condition?
Q22
What will be the output of the following C code? #include <stdio.h> int main() { int a = 1; if (a--) printf("True"); if (a++) printf("False"); }
Q23
What will be the output of the following C code? #include <stdio.h> int main() { int i = 0, j = 0; while (i < 2) { l1: i++; while (j < 3) { printf("loop\n"); goto l1; } } }
Q24
What will be the output of the following C code? #include <stdio.h> int main() { int i = 0; for (foo(); i == 1; i = 2) printf("In for loop\n"); printf("After loop\n"); } int foo() { return 1; }
Q25
What will be the output of the following C code? #include <stdio.h> int main() { switch (printf("Do")) { case 1: printf("First\n"); break; case 2: printf("Second\n"); break; default: printf("Default\n"); break; } }