# Questions on Pointers in C

By Anjnee Bhatnagar|Updated : July 18th, 2022

Questions on Pointers in C are provided here for candidates who are actively preparing for the GATE CSE exam 2023. Questions on Pointers in C can provide a quick overview of the types of questions to be expected in the exam on this topic.

Pointers will be better understood by using objective-based MCQ questions and answers. Five specially picked questions are mentioned here ranging from basic to high-level questions on pointers in C for the GATE exam pattern. Attempt and get the detailed solution to questions on Pointers in C mentioned in this article.

## Question 1 on Pointers in C

Can you combine the following two statements into one?

char *p;

p= (char*) malloc (100);

1. char p = *malloc(100);
2. char *p = (char) malloc(100);
3. char *p = (char*)malloc(100);
4. char *p = (char *)(malloc*)(100);

Answer: C. char *p = (char*)malloc(100);

Solution:

Yes, the given two statements can be combined as follows: char *p = (char*)malloc(100);. It is following the syntax to allocate memory to a character pointer variable p.

## Question 2 on Pointers in C

A pointer is?

1. A keyword used to create variables
2. A variable that stores the address of an instruction
3. A variable that stores the address of another variable
4. All of the above

Solution:

A pointer variable is defined as a variable that is used to store the address of another variable. A pointer variable is denoted by the * operator also called as dereference operator.

## Question 3 on Pointers in C

The operator used to get the value at the address stored in a pointer variable is?

1. *
2. &
3. &&
4. ||

Solution:

To obtain the value stored at the address in a pointer variable the * operator is used. “&” is denoted as the address operator in C. While “&&” and “||” are logical AND and logical OR operators in C.

## Question 4 on Pointers in C

Consider the following code:

int a, *x, *y;

x = &a;

y = &a;

Which of the following statement is incorrect concerning pointers?

1. y – x
2. y – 3
3. x + y
4. x + 1

Solution:

Here, we check the options one by one.

Option A:
y here denotes the address of the 8th element of the array whereas x denotes the address of the 6th element of the array. So, the y - x operation can be easily calculated and it will produce the output 2.

Option B:
We can subtract 3 from the pointer y as then it would point to the 5th element of the array.

Option C:
We can’t perform the addition of x and y pointer, as adding these two pointers points to some garbage value.

Option D:
We can add 1 to the pointer x as then it would point to the 7th element of the array.

Hence, option C is the correct answer.

## Question 5 on Pointers in C

Which of the following represents the below terminology?
“ x is a pointer to array which is containing 5 integer pointers.”

1. int *x 
2. int (*x) 
3. int *(*x) 
4. int x 

Solution:

The correct representation of x is a pointer to an array which is containing 5 integer pointers: int *(*x) .

☛ Related Questions: GradeStack Learning Pvt. Ltd.Windsor IT Park, Tower - A, 2nd Floor, Sector 125, Noida, Uttar Pradesh 201303 help@byjusexamprep.com