Tutorials  Articles  Notifications  Login  Signup

Introduction C Programming variables (Set 1) C Programming variables (Set 2) C Programming variable and function declaration (set 3) Pointers in C Pointers (set 2)



Pointers in C



MCQ problems on C Pointers.


1.

Which operator is used to access data members of a structure, with a variable that is pointer to that structure ?

A.

->

B.

&

C.

.

D.

*



2.

Take a look at following code:

(void*)0

What does it depicts ?

A.

It represents a NULL pointer

B.

Syntax Error

C.

It represents a void pointer

D.

None of the options



3.

Which of the following header file(s) contain definition for NULL macro ?

A.

Only stdio.h

B.

Only math.h

C.

Only stdio.h and stddef.h

D.

None of the options



4.

What is the size of a pointer variable on Linux ?

A.

1 byte

B.

2 byte

C.

4 byte

D.

8 byte



5.

How do you access value at position arr[i][j][k][l] using pointer ?

A.

((arr+i)+j+k+l)

B.

(((arr+i)+j)+k+l)

C.

*(*(*(*(arr+i)+j)+k)+l)

D.

((((arr+i)+j)+k)+l)



6.

Which operator is used with pointer to access value at the address to which pointer points ?

A.

&

B.

*

C.

->

D.

&&



7.

Which of the following is correct about pointers ?

A.

It is a keyword to declare special types of variable

B.

It is a variable that stores address of any variable

C.

It allocates memory for any variable

D.

All of the options



8.

Take a look the following piece of code:

char *x;
x = (char*) malloc(10);

Which of the following piece of code is equivalent to it ?

A.
char x = *malloc(10);

 

B.
char *x = (char *)(malloc*)(10);

 

C.
char *x = (char) malloc(10);

 

D.
char *x = (char*)malloc(10);

 



9.

What should be the output of following code:

#include<stdio.h>

int main()
{
    static char *s[] = {"hackersfriend", "coder", "learning", "lab"};
    char **ptr[] = {s+3, s+2, s+1, s}, ***p;
    p = ptr;
    ++p;
    printf("%s", **p+1);
    return 0;
}

 

A.

earning

B.

oder

C.

ackersfriend

D.

None of the options



10.

What would be output of the following code:

#include<stdio.h>

int main()
{
    int x=4, *y, z;
    y = &x;
    printf("%d", x**y*x+*y+x);
    return 0;
}

 

A.

4

B.

5

C.

64

D.

72





HackerFriend Logo

Join the community of 1 Lakh+ Developers

Create a free account and get access to tutorials, jobs, hackathons, developer events and neatly written articles.


Create a free account