Question 1 of 25
Hints left: 3
Q1
What will be the output of the following C code? #include <stdio.h> void main() { char a[10][5] = {"hi", "hello", "fellows"}; printf("%s", a[2]); }
Q2
What will be the output of the following C code? #include <stdio.h> int main() { char *str = "hello, world\n"; str[5] = '.'; printf("%s\n", str); return 0; }
Q3
What will be the output of the following C code? #include <stdio.h> void main() { int a[3] = {1, 2, 3}; int *p = a; int *r = &p; printf("%d", (**r)); }
Q4
What will be the output of the following C code? #include <stdio.h> void foo(int *ary[]); int main() { int ary[2][3]; foo(ary); } void foo(int *ary[]) { int i = 10, j = 2, k; ary[0] = &i; ary[1] = &j; *ary[0] = 2; for (k = 0;k < 2; k++) printf("%d\n", *ary[k]); }
Q5
What will be the output of the following C code (run without any command line arguments)? #include <stdio.h> int main(int argc, char *argv[]) { while (*argv++ != NULL) printf("%s\n", *argv); return 0; }
Q6
What will be the output of the following C code? #include <stdio.h> void main() { int a[2][3] = {1, 2, 3, , 4, 5}; int i = 0, j = 0; for (i = 0; i < 2; i++) for (j = 0; j < 3; j++) printf("%d", a[i][j]); }
Q7
What will be the output of the following C code? #include <stdio.h> void main() { char s[] = "hello"; s++; printf("%c\n", *s); }
Q8
What makes the following declaration denote? char *str[5];
Q9
What will be the output of the following C code? #include <stdio.h> int main() { char *str = "hello world"; char strary[] = "hello world"; printf("%d %d\n", sizeof(str), sizeof(strary)); return 0; }
Q10
What will be the output of the following C code? #include <stdio.h> int main() { int ary[2][3]; ary[][] = {{1, 2, 3}, {4, 5, 6}}; printf("%d\n", ary[1][0]); }
Q11
What will be the output of the following C code? #include <stdio.h> int main() { int a[4] = {1, 2, 3, 4}; int b[4] = {1, 2, 3, 4}; int n = &b[3] - &a[2]; printf("%d\n", n); }
Q12
What will be the output of the following C code? #include <stdio.h> int main() { char *p[1] = {"hello"}; printf("%s", (p)[0]); return 0; }
Q13
What will be the output of the following C code? #include <stdio.h> void f(int a[][3]) { a[0][1] = 3; int i = 0, j = 0; for (i = 0; i < 2; i++) for (j = 0; j < 3; j++) printf("%d", a[i][j]); } void main() { int a[2][3] = {0}; f(a); }
Q14
What will be the output of the following C code? #include <stdio.h> int main() { int i = 0, j = 1; int *a[] = {&i, &j}; printf("%d", (*a)[1]); return 0; }
Q15
An array of similar data types which themselves are a collection of dissimilar data type are . . . . . . . .
Q16
What will be the output of the following C code (considering sizeof char is 1 and pointer is 4)? #include <stdio.h> int main() { char *a[2] = {"hello", "hi"}; printf("%d", sizeof(a)); return 0; }
Q17
In linux, argv[0] by command-line argument can be occupied by . . . . . . . .
Q18
Which is true for b, if b is defined as "int *b[10];"?
Q19
What will be the output of the following C code? #include <stdio.h> int main() { int i = 11; int *p = &i; foo(&p); printf("%d ", *p); } void foo(int *const *p) { int j = 10; *p = &j; printf("%d ", **p); }
Q20
Which of the following is the correct syntax to send an array as a parameter to function?
Q21
What will be the output of the following C code? #include <stdio.h> void (*(f)())(int, float); typedef void (*(*x)())(int, float); void foo(int i, float f); int main() { x = f; x(); } void (*(f)())(int, float) { return foo; } void foo(int i, float f) { printf("%d %f\n", i, f); }
Q22
What will be the output of the following C code? #include <stdio.h> void main() { int a[3] = {1, 2, 3}; int *p = a; int *r = &p; printf("%d", (**r)); }
Q23
Comment on the output of the following C code. #include <stdio.h> int main() { int a = 10; int **c -= &&a; }
Q24
Is the below declaration legal? int* ((*x)())[2];
Q25
What will be the output of the following C code? #include <stdio.h> struct student { int no; char name[20]; }; void main() { struct student s; s.no = 8; printf("hello"); }