Explore topic-wise MCQs in Pointers.

This section includes 79 Mcqs, each offering curated multiple-choice questions to sharpen your Pointers knowledge and support exam preparation. Choose a topic below to get started.

51.

What is the output of this C code? int main() { char *p = NULL; char *q = 0; if (p) printf(" p "); else printf("nullp"); if (q) printf("q n"); else printf(" nullq n"); }

A. nullp nullq
B. Depends on the compiler
C. x nullq where x can be p or nullp depending on the value of NULL
D. p q
Answer» B. Depends on the compiler
52.

Will the program compile in Turbo C? #include int main() { int a=10, *j; void *k; j=k=&a; j++; k++; printf("%u %u n", j, k); return 0; }

A. Yes
B. No
Answer» C.
53.

Will the following program give any warning on compilation in TurboC (under DOS)? #include int main() { int *p1, i=25; void *p2; p1=&i; p2=&i; p1=p2; p2=p1; return 0; }

A. Yes
B. No
Answer» C.
54.

The following program reports an error on compilation. #include int main() { float i=10, *j; void *k; k=&i; j=k; printf("%f n", *j); return 0; }

A. True
B. False
Answer» C.
55.

Is this a correct way for NULL pointer assignment? int i=0; char *q=(char*)i;

A. Yes
B. No
Answer» C.
56.

Is there any difference between the following two statements? char *p=0; char *t=NULL;

A. Yes
B. No
Answer» C.
57.

Will the program compile? #include int main() { char str[5] = "IndiaBIX"; return 0; }

A. True
B. False
Answer» B. False
58.

Which of the statements is correct about the program? #include int main() { float a=3.14; char *j; j = (char*)&a; printf("%d n", *j); return 0; }

A. It prints ASCII value of the binary number present in the first byte of a float variable a.
B. It prints character equivalent of the binary number present in the first byte of a float variable a.
C. It will print 3
D. It will print a garbage value
Answer» B. It prints character equivalent of the binary number present in the first byte of a float variable a.
59.

Which of the statements is correct about the program? #include int main() { int i=10; int *j=&i; return 0; }

A. j and i are pointers to an int
B. i is a pointer to an int and stores address of j
C. j is a pointer to an int and stores address of i
D. j is a pointer to a pointer to an int and stores address of i
Answer» D. j is a pointer to a pointer to an int and stores address of i
60.

Point out the compile time error in the program given below. #include int main() { int *x; *x=100; return 0; }

A. Error: invalid assignment for x
B. Error: suspicious pointer conversion
C. No error
D. None of above
Answer» D. None of above
61.

Are the expression *ptr++ and ++*ptr are same?

A. True
B. False
Answer» C.
62.

What is the output of this C code? void main() { int k = 5; int *p = &k; int **m = &p; printf("%d%d%d n", k, *p, **p); }

A. 5 5 5
B. 5 5 junk value
C. 5 junk value
D. Compile time error
Answer» E.
63.

Which of the following statements correct about k used in the below statement? char ****k;

A. k is a pointer to a pointer to a pointer to a char
B. k is a pointer to a pointer to a pointer to a pointer to a char
C. k is a pointer to a char pointer
D. k is a pointer to a pointer to a char
Answer» C. k is a pointer to a char pointer
64.

What is the output of this C code? void main() { int k = 5; int *p = &k; int **m = &p; printf("%d%d%d n", k, *p, **m); }

A. 5 5 5
B. 5 5 junk value
C. 5 junk value
D. Run time error
Answer» B. 5 5 junk value
65.

Which of the following are correct syntaxes to send an array as a parameter to function:

A. func(&array);
B. func(array);
C. func(*array);
D. func(array[size]);
Answer» C. func(*array);
66.

Which of the following does not initialize ptr to null (assuming variable declaration of a as int a=0)?

A. int *ptr = &a;
B. int *ptr = &a &a;
C. int *ptr = a a;
D. All of the mentioned
Answer» B. int *ptr = &a &a;
67.

Comment on the following? const int *ptr;

A. You cannot change the value pointed by ptr
B. You cannot change the pointer ptr itself
C. Both (a) and (b)
D. You can change the pointer as well as the value pointed by it
Answer» B. You cannot change the pointer ptr itself
68.

What is the output of this C code? int main() { int *ptr, a = 10; ptr = &a; *ptr += 1; printf("%d,%d/n", *ptr, a); }

A. 10,10
B. 10,11
C. 11,10
D. 11,11
Answer» E.
69.

What is the output of the code below? int main() { int i = 10; int *const p = &i; foo(&p); printf("%d n", *p); } void foo(int **p) { int j = 11; *p = &j; printf("%d n", **p); }

A. 11 11
B. Undefined behaviour
C. Compile time error
D. Segmentation fault/code-crash
Answer» B. Undefined behaviour
70.

What is the output of this C code? 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); }

A. Compile time error
B. 10 10
C. Undefined behaviour
D. 10 11
Answer» B. 10 10
71.

What is the output of this C code? int main() { int i = 97, *p = &i; foo(&p); printf("%d ", *p); return 0; } void foo(int **p) { int j = 2; *p = &j; printf("%d ", **p); }

A. 2 2
B. 2 97
C. Undefined behaviour
D. Segmentation fault/code crash
Answer» B. 2 97
72.

What is the output of this C code? int main() { int i = 10; int *p = &i; foo(&p); printf("%d ", *p); printf("%d ", *p); } void foo(int **const p) { int j = 11; *p = &j; printf("%d ", **p); }

A. 11 11 11
B. 11 11 Undefined-value
C. Compile time error
D. Segmentation fault/code-crash
Answer» C. Compile time error
73.

What is the output of this C code? int main() { int i = 97, *p = &i; foo(&i); printf("%d ", *p); } void foo(int *p) { int j = 2; p = &j; printf("%d ", *p); }

A. 2 97
B. 2 2
C. Compile time error
D. Segmentation fault/code crash
Answer» B. 2 2
74.

What is the output of this C code? void foo(float *); int main() { int i = 10, *p = &i; foo(&i); } void foo(float *p) { printf("%f n", *p); }

A. 10.000000
B. 0.000000
C. Compile time error
D. Undefined behaviour
Answer» C. Compile time error
75.

What is the output of this C code? void foo(int*); int main() { int i = 10, *p = &i; foo(p++); } void foo(int *p) { printf("%d n", *p); }

A. 10
B. Some garbage value
C. Compile time error
D. Segmentation fault
Answer» B. Some garbage value
76.

What will be the output of the following C code? #include void foo(float *); int main() { int i = 10, *p = &i; foo(&i); } void foo(float *p) { printf("%f n", *p); }

A. 10.000000
B. 0.000000
C. Compile time error
D. Undefined behaviour
Answer» C. Compile time error
77.

What is the output of this C code? void main() { int a[3] = {1, 2, 3}; int *p = a; int **r = &p; printf("%p %p", *r, a); }

A. Different address is printed
B. 1 2
C. Same address is printed.
D. 1 1
Answer» D. 1 1
78.

What is the output of this C code? void main() { int a[3] = {1, 2, 3}; int *p = a; int *r = &p; printf("%d", (**r)); }

A. 1
B. Compile time error
C. Address of a
D. Junk value
Answer» C. Address of a
79.

What is the output of this C code? void main() { int k = 5; int *p = &k; int **m = &p; **m = 6; printf("%d n", k); }

A. 5
B. Compile time error
C. 6
D. Junk
Answer» D. Junk