22226 PCI MCQ (Programming in C) | Unit 6: Pointers

cwipedia

Department of Computer Engineering

Academic Year 2020-21


Class: Computer & IT

Subject: 22226 PCI (Programming in C) MCQ 


Unit 6: Pointers

MCQ Question Bank with Answers


2nd SEM ALL SUBJECT MCQ:           click here

     



To Download PDF scroll to the bottom



1. A pointer is

A. A variable that stores address of an instruction

B. A variable that stores address of other variable

C. A keyword used to create variables

D. None of these

Ans : B


2. The reason for using pointers in a C program is

A. Pointers allow different functions to share and modify their local variables.

B. To pass large structures so that complete copy of the structure can be avoided.

C. Pointers enable complex “linked" data structures like linked lists and binary trees.

D. All of the above

Ans : D


3. How can you write a[i][j][k][l] in equivalent pointer expression?

A. (((***(a+i)+j)+k)+l)

B. ((**(*(a+i)+j)+k)+l)

C. (*(*(*(a+i)+j)+k)+l)

D. *(*(*(*(a+i)+j)+k)+l)

Ans : D


4. What is the base data type of a pointer variable by which the memory would be allocated to it?

a) int

b) float

c) No datatype

d) Depends upon the type of the variable to which it is pointing

e) unsigned int

 Ans: e




5. Prior to using a pointer variable it should be

a) Declared

b) Initialized

c) Both declared and initialized

d) None of these

Answer: C


6. In C a pointer variable to an integer can be created by the declaration

a) int p*;

b) int *p;

c) int +p;

d) int $p;

Answer: B


7. A pointer variable can be

a) Passed to a function

b) Changed within a function

c) Returned by a function

d) Can be assigned an integer value

Answer: C


8. What will be the output of the following C code?

void main() {

  int a[] = {1,2,3,4,5}, *p;

  p = a;

  ++*p;

  printf("%d ", *p);

p += 2;

  printf("%d ", *p);

}

a) 24

b) 34

c) 22

d) 23

Answer: D


9. What is the output of the following C code?

  char *ptr;

  char mystring[] = "abcdefg";

  ptr = myString;

  ptr += 5;

a) fg 

b) efg 

c) defg 

d) cdefg 

e) bcdefg

Answer: A


10. Will this program compile?

int main() {

  char str[5] = "LetsFind";

  return 0;

}

a) True

b) False

Answer: A


11. Is the NULL pointer the same as an uninitialised pointer?

a) True

b) False

Answer: B


12. Which of the following statements is 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: B


13. What will be the output of the program?

char *p = 0;

char *t = NULL;

a) Yes

b) No

Answer: B


Download



Happy Learning!

cwipedia.in



Comments