QUIZ ON : C LANGUAGE - POINTERS

POINTERS

00:00:00

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# : 01 out of 20

Which of the following expression is equivalent to ++*ptr?

Option A. (*ptr)++
Option B. ++*(ptr)
Option C. (ptr)*++
Option D. (ptr)++*
True Answer A

Explanation :

Which of the following expression is equivalent to ++*ptr?

Question No# : 02 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# : 03 out of 20

Which of the following statements will not dynamically allocate space to store 10 integers?

Option A. int a[10];
Option B. int *p = (int *) malloc(10 * sizeof(int));
Option C. int *p = (int *) calloc(10, sizeof(int));
Option D. none of the above
True Answer A

Explanation :

Which of the following statements will not dynamically allocate space to store 10 integers?

Question No# : 04 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# : 05 out of 20

The expression a[0] and *a[0] are same for int a[100].

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

Explanation :

The expression a[0] and *a[0] are same for int a[100].

Question No# : 06 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# : 07 out of 20

The return type of malloc function is void.

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

Explanation :

The return type of malloc function is void.

Question No# : 08 out of 20

Structures cannot contain a pointer to itself.

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

Explanation :
Structure can contain a Pointer to itself. Such structures are called self-referential structures.

Structures cannot contain a pointer to itself.

Question No# : 09 out of 20

*ptr++ is equivalent to

Option A. ptr++
Option B. *ptr
Option C. ++ptr
Option D. ++*ptr
True Answer D

Explanation :

*ptr++ is equivalent to

Question No# : 10 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# : 11 out of 20

Array is passed to a function using 'call by value' method.

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

Explanation :

Array is passed to a function using 'call by value' method.

Question No# : 12 out of 20

*ptr ++ is equivalent to

Option A. ptr++
Option B. *ptr
Option C. ++ptr
Option D. ++*ptr
True Answer D

Explanation :

*ptr ++ is equivalent to

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

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# : 15 out of 20

Identify the invalid declaration:

Option A. int &p;
Option B. int *p[10];
Option C. int **p;
Option D. int *p[ ];
True Answer A

Explanation :

Identify the invalid declaration:

Question No# : 16 out of 20

A pointer is

Option A. A keyword used to create variables
Option B. A variable that stores address of an instruction
Option C. A variable that stores address of other variable
Option D. All of the above
True Answer C

Explanation :

A pointer is

Question No# : 17 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# : 18 out of 20

In ‘C’, if you pass an array as an argument to a function, value of elements in array actually gets passed?

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

Explanation :

In ‘C’, if you pass an array as an argument to a function, value of elements in array actually gets passed?

Question No# : 19 out of 20

The return type of malloc function is void.

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

Explanation :

The return type of malloc function is void.

Question No# : 20 out of 20