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() { int ch; printf("enter a value between 1 to 2:"); scanf("%d", &ch); switch (ch) { case 1: printf("1\n"); default: printf("2\n"); } }
Q2
What will be the output of the following C code? #include <stdio.h> int main() { int a = 1; switch (a) { case a: printf("Case A "); default: printf("Default"); } }
Q3
What will be the output of the following C code? #include <stdio.h> int main() { int a = 1, b = 1; switch (a) { case a*b: printf("yes "); case a-b: printf("no\n"); break; } }
Q4
What is the purpose of a function prototype in C?
Q5
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() { char *ch; printf("enter a value between 1 to 3:"); scanf("%s", ch); switch (ch) { case "1": printf("1"); break; case "2": printf("2"); break; } }
Q6
Which of the following cannot be used as LHS of the expression in for (exp1;exp2; exp3)?
Q7
Comment on the output of the following C code. #include <stdio.h> int main() { int a = 1; switch (a) case 1: printf("%d", a); case 2: printf("%d", a); case 3: printf("%d", a); default: printf("%d", a); }
Q8
What will be the output of the following C code? #include <stdio.h> void main() { double k = 0; for (k = 0.0; k < 3.0; k++); printf("%lf", k); }
Q9
What will be the output of the following C code? #include <stdio.h> void main() { int i = 0; while (i < 10) { i++; printf("hi\n"); while (i < 8) { i++; printf("hello\n"); } } }
Q10
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); }
Q11
What will be the output of the following C code? #include <stdio.h> int main() { int i = 0, j = 0; for (i; i < 2; i++){ for (j = 0; j < 3; j++) { printf("1\n"); break; } printf("2\n"); } printf("after loop\n"); }
Q12
What will be the output of the following C code? #include <stdio.h> void main() { int i = 2; do { printf("Hi"); } while (i < 2) }
Q13
What will be the output of the following C code? #include <stdio.h> void main() { int x = 5; if (x < 1) printf("hello"); if (x == 5) printf("hi"); else printf("no"); }
Q14
What will be the output of the following C code? #include <stdio.h> int main() { for (int i = 0;i < 1; i++) printf("In for loop\n"); }
Q15
What will be the output of the following C code? #include <stdio.h> void main() { int i = 0, j = 0; for (i = 0;i < 5; i++) { for (j = 0;j < 4; j++) { if (i > 1) break; } printf("Hi \n"); } }
Q16
In C, what is a function primarily used for?
Q17
What will be the output of the following C code? #include <stdio.h> int main() { int i = 0; for (i++; i == 1; i = 2) printf("In for loop "); printf("After loop\n"); }
Q18
What will be the output of the following C code? #include <stdio.h> void main() { int i = 0; int j = 0; for (i = 0;i < 5; i++) { for (j = 0;j < 4; j++) { if (i > 1) continue; printf("Hi \n"); } } }
Q19
The C code 'for(;;)' represents an infinite loop. It can be terminated by . . . . . . . .
Q20
What will be the output of the following C code? #include <stdio.h> void main() { int i = 0; while (++i) { printf("H"); } }
Q21
What will be the output of the following C code? #include <stdio.h> int main() { printf("%d ", 1); l1:l2: printf("%d ", 2); printf("%d\n", 3); }
Q22
In C, how are function arguments passed by default?
Q23
What is the result of the expression sqrt(16) in C, assuming proper inclusion of the math library?
Q24
What will be the output of the following C code? #include <stdio.h> int main() { int i = 0; for (; ; ;) printf("In for loop\n"); printf("After loop\n"); }
Q25
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"); } }