1. #include “stdio.h” void fun(int *ptr) { *ptr = 30; } int main() { int y = 20; fun(&y); printf(“%d”, y); return 0; } (a) 20 (b) 30 (c) Compiler Error (d) Runtime Error 2. int main() { char *ptr
Strings in C
1. main() { char c[] = “SCABHOPAL”; char *p =c; printf(“%s”, p + p[4] – p[3]) ; } (a) PAL (b) HOPAL (c) BHOPAL (d) SCABHOPAL 2. #include “stdio.h” int main() { char str[] = “ILoveYou”; printf(“%s %s %s\n”, &str[5],
Arrays in C
1. #include “stdio.h” int main() { int arr[5]; // Assume that base address of arr is 2000 and size of integer // is 32 bit arr++; printf(“%u”, arr); return 0; } (a) 2002 (b) 2004 (c) 2020 (d) lvalue required
Recursion in C
1. #include “stdio.h” int fun(int n) { if (n == 4) return n; else return 2*fun(n+1); } int main() { printf(“%d “, fun(2)); return 0; } (a) 4 (b) 8 (c) 16 (d) Runtime Error 2. Consider the following recursive
functions in C
1. #include “stdio.h” int main() { int i = 5; printf(“%d %d %d”, i++, i++, i++); return 0; } (a) 7 6 5 (b) 5 6 7 (c) 7 7 7 (d) Compiler Dependent 2. #include “stdio.h” int main() {
Loops in C
1. #include “stdio.h” int main() { int i; for (i = 9; i!=0; i–) printf(“i = %d”, i–); return 0; } (a) 9 7 5 3 1 (b) 9 8 7 6 5 4 3 2 1 (c) Infinite Loop
Decision Control in C
1. Find output of the following program #include “stdio.h” int main() { int i; if (printf(“0”)) i = 4; else i = 6; printf(“%d”, i); return 0; } (a) 4 (b) 6 (c) 04 (d) 06 2. Find output of
Operators in C
1. Find output of the following program #include “stdio.h” int main() { int x, y = 5, z = 5; x = y == z; printf(“%d”, x); getchar(); return 0; } (a) Compiler Error (b) 0 (c) 1 (d) 8