Question 1 of 25
Hints left: 3
Q1
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", strlen(str), strlen(strary)); return 0; }
Q2
What will be the output of the following C code? #include <stdio.h> void main() { char *s = "hello"; char *p = s; printf("%p\t%p", p, s); }
Q3
What will be the output of the following C code? #include <stdio.h> int main() { char a[1][5] = {"hello"}; printf("%s", a[0]); return 0; }
Q4
What will be the output of the following C code? #include <stdio.h> int main() { int ary[4] = {1, 2, 3, 4}; int *p = ary + 3; printf("%d\n", p[-2]); }
Q5
What will be the output of the following C code? #include <stdio.h> int main() { char *str = "hello, world!!\n"; char strc[] = "good morning\n"; strcpy(strc, str); printf("%s\n", strc); return 0; }
Q6
What will be the output of the following C code (if run with no options or arguments)? #include <stdio.h> int main(int argc, char *argv[]) { printf("%d\n", argc); return 0; }
Q7
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("%p %p", *r, a); }
Q8
What will be the output of the following C code? #include <stdio.h> void main() { char *s= "hello"; char *p = s; printf("%c\t%c", 1[p], s[1]); }
Q9
What will be the output of the following C code? #include <stdio.h> struct student { int no = 5; char name[20]; }; void main() { struct student s; s.no = 8; printf("hello"); }
Q10
What will be the output of the following C code? #include <stdio.h> int mul(int a, int b, int c) { return a * b * c; } void main() { int *function_pointer; function_pointer = mul; printf("The product of three numbers is:%d", function_pointer(2, 3, 4)); }
Q11
What will be the output of the following C code? #include <stdio.h> int x = 0; void main() { int *ptr = &x; printf("%p\n", ptr); x++; printf("%p\n ", ptr); }
Q12
A program that has no command line arguments will have argc . . . . . . . .
Q13
Comment on the following C statement. const int *ptr;
Q14
An array of strings can be initialized by . . . . . . . .
Q15
What will be the output of the following C code? #include <stdio.h> int main() { char *a = {"p", "r", "o", "g", "r", "a", "m"}; printf("%s", a); }
Q16
What will be the output of the following C code? #include <stdio.h> void f(int a[2][]) { 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); }
Q17
Read the following expression? void (*ptr)(int);
Q18
What will be the output of the following C code? #include <stdio.h> void main() { char a[10][5] = {"hi", "hello", "fellows"}; printf("%p\n", a); printf("%p", a[0]); }
Q19
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; }
Q20
Which of the following is not possible in C?
Q21
What will be the output of the following C code? #include <stdio.h> void first() { printf("Hello World"); } void main() { void *ptr() = first; ptr++ ptr(); }
Q22
Which of the following can never be sent by call-by-value?
Q23
What is argv[0] in command line arguments?
Q24
What will be the output of the following C code on a 32-bit system? #include <stdio.h> void main() { char *a[10] = {"hi", "hello", "how"}; printf("%d\n", sizeof(a[1])); }
Q25
What will be the output of the following C code? #include <stdio.h> int main() { void *p; int a[4] = {1, 2, 3, 4}; p = &a[3]; int *ptr = &a[2]; int n = (int*)p - ptr; printf("%d\n", n); }