QUIZ ON : C LANGUAGE - POINTERS

POINTERS

00:00:00

NULL pointer points the base address of segment.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer B

Explanation :

NULL pointer points the base address of segment.

Question No# : 01 out of 20

If char *p = "Structured Programming", then p[5] is 'c'.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer B

Explanation :

If char *p = "Structured Programming", then p[5] is 'c'.

Question No# : 02 out of 20

size of a pointer, which points to a structure, depends on size of a structure.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :

size of a pointer, which points to a structure, depends on size of a structure.

Question No# : 03 out of 20

Which of the following defines a variable ‘a’ as an array of pointers to integers?

Option A. int *b[10], a[10];
Option B. int *b, a[10];
Option C. int b, *a[10];
Option D. int b, (*a)[10];
True Answer C

Explanation :

Which of the following defines a variable ‘a’ as an array of pointers to integers?

Question No# : 04 out of 20

Size of the pointer variable depends on the data type that it points to.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :

Size of the pointer variable depends on the data type that it points to.

Question No# : 05 out of 20

NULL pointer is not same as an uninitialized pointer.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :

NULL pointer is not same as an uninitialized pointer.

Question No# : 06 out of 20

How will you free the allocated memory?

Option A. remove(var-name);
Option B. free(var-name);
Option C. delete(var-name);
Option D. dalloc(var-name);
True Answer B

Explanation :

How will you free the allocated memory?

Question No# : 07 out of 20

Declaration int *(*p) int(*a) is

Option A. A pointer to function that accept an integer argument and return an integer
Option B. A pointer to a, which returns an integer
Option C. A pointer to subroutine which returns an integer
Option D. None of the above
True Answer A

Explanation :

Declaration int *(*p) int(*a) is

Question No# : 08 out of 20

How many bytes are occupied by near, far and huge pointers (DOS)?

Option A. near=2 far=4 huge=4
Option B. near=4 far=8 huge=8
Option C. near=2 far=4 huge=8
Option D. near=4 far=4 huge=8
True Answer A

Explanation :
near=2, far=4 and huge=4 pointers exist only under DOS. Under windows and Linux every pointers is 4 bytes long.

How many bytes are occupied by near, far and huge pointers (DOS)?

Question No# : 09 out of 20

Are the three declarations char **apple, char *apple[], and char apple[][] same?

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :

Are the three declarations char **apple, char *apple[], and char apple[][] same?

Question No# : 10 out of 20

With every use of a memory allocation function, what function should be used to release allocated memory which is no longer needed?

Option A. unalloc()
Option B. Dropmem()
Option C. Dealloc()
Option D. free()
True Answer D

Explanation :

With every use of a memory allocation function, what function should be used to release allocated memory which is no longer needed?

Question No# : 11 out of 20

Pointers are used in a program to allocate memory before the program execution.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer B

Explanation :

Pointers are used in a program to allocate memory before the program execution.

Question No# : 12 out of 20

malloc() returns a float pointer if memory is allocated for storing float's and a double pointer if memory is allocated for storing double's.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer B

Explanation :

malloc() returns a float pointer if memory is allocated for storing float's and a double pointer if memory is allocated for storing double's.

Question No# : 13 out of 20

Two pointer variables cannot be subtracted.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :

Two pointer variables cannot be subtracted.

Question No# : 14 out of 20

In the declaration int(*p)() p is a pointer to a function that returns an integer.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer B

Explanation :

In the declaration int(*p)() p is a pointer to a function that returns an integer.

Question No# : 15 out of 20

If p is a pointer then the expression p = p + 1; adds 1 to the value of p regardless of p's type.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :

If p is a pointer then the expression p = p + 1; adds 1 to the value of p regardless of p's type.

Question No# : 16 out of 20

If a variable is a pointer to a structure, then which of the following operator is used to access data members of the structure through the pointer variable.

Option A. ‘.’
Option B. ‘&’
Option C. ‘*’
Option D. ‘->’
True Answer D

Explanation :

If a variable is a pointer to a structure, then which of the following operator is used to access data members of the structure through the pointer variable.

Question No# : 17 out of 20

Are the three declarations char **apple, char *apple[], and char apple[][] same?

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer B

Explanation :

Are the three declarations char **apple, char *apple[], and char apple[][] same?

Question No# : 18 out of 20

Which header file should be included to use functions like malloc() and calloc()?

Option A. memory.h
Option B. stdlib.h
Option C. string.h
Option D. dos.h
True Answer B

Explanation :

 In C, you should include stdlib.h. This will give you the function prototypes for the family of malloc functions (malloccalloc, realloc, and free). Some compiler vendors provide access to these functions through other header files as well, but stdlib.h is the most portable one to use.

Which header file should be included to use functions like malloc() and calloc()?

Question No# : 19 out of 20

Structures cannot contain a pointer to itself.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer B

Explanation :

Structures cannot contain a pointer to itself.

Question No# : 20 out of 20