Void Pointers MCQ: Void Pointers Multiple Choice Questions

Void Pointers MCQ with answers and explanations for placement tests and job interviews. These solved Void Pointers MCQ questions are useful for the campus placement for all freshers including Engineering Students, MCA students, Computer and IT Engineers, etc.

Our Void Pointers MCQ ( Void Pointers Multiple Choice Questions and Answer )  focuses on all areas of R Language Programming. We will also regularly update the Void Pointers MCQs and the most interesting thing is that questions come in a random sequence. So every time you will feel new questions.

We have already published a blog post on void pointers. If you want you can also see this blog post. It would help you in your preparation. “Introduction of void pointers with its application“.

Guideline of Void Pointers MCQ:

This MCQ on Void Pointers is intended for checking your Void Pointers knowledge and understanding. It takes 40 minutes to pass the Void Pointer MCQ. If you don’t finish the MCQ on Void Pointers within the mentioned time, all the unanswered questions will count as wrong. You can miss the questions by clicking the “Next” button and return to the previous questions by the “Previous” button. Every unanswered question will count as wrong. MCQ on Void Pointer has features of randomization which feel you a new question set at every attempt.

In these Void Pointer MCQs, we have also implemented a feature that not allowed the user to see the next question or finish the quiz without attempting the current void pointer MCQ.

Note: Your score along with correct answers will be visible after answering all of these questions.

3 votes, 5 avg

You have 40 minutes to take the Void Pointer MCQs

Your time has been Over.


Void Pointer MCQ

C Programming Multiple Choice Questions And Answers

Void Pointer MCQ: Void Pointer Multiple Choice Questions and Answers

1 / 21

What is the output?

#include <stdio.h>

int main()
{
    void *pvData = NULL;

    printf("%d\n\n",sizeof(pvData));

    return 0;
}

 

2 / 21

#include<stdlib.h>
#include <stdio.h>

int main()
{
    int x = 4;
    float y = 5.5;

    //A void pointer
    void *ptr;
    ptr = &x;

    printf("Integer variable is = %d", *( (int*) ptr) );

    ptr = &y;
    printf("\nFloat variable is= %f", *( (float*) ptr) );

    return 0;
}

 

3 / 21

What we can’t do on a void pointer?

4 / 21

What is the size of the void pointer in C?

5 / 21

Pick the best statement for the following program snippet:

#include <stdio.h>

int main()
{
    //Suppose address of var is 2000
    int var;

    void *ptr = &var;

    *ptr = 5;

    printf("var=%d and *ptr=%d",var,*ptr);

    return 0;
}

 

6 / 21

In the below statement, ptr1 and ptr2 are uninitialized pointers to int i.e. they are pointing to some random address that may or may not be valid address. int* ptr1, ptr2;

7 / 21

What is the output?

#include<stdio.h>

int main()
{
    char *ptr = "Aticleworld";

    printf("%c\n", *&*&*ptr);

    return 0;
}

 

8 / 21

The reason for using pointers in a C program is?

9 / 21

What is the output?

#include<stdio.h>

int main()
{
    int a = 12;

    void *ptr = (int *)&a;

    printf("%d", *ptr);

    return 0;
}

 

10 / 21

int main()
{
    void *pVoid;
    
    pVoid = (void*)0;
    
    printf("%lu",sizeof(pVoid));
    
    return 0;
}

Pick the best statement for the above C program snippet.

11 / 21

‘ptrdata’ is a pointer to a data type. The expression *ptrdata++ is evaluated as (in C++) :

12 / 21

The void pointer can point to which type of object?

13 / 21

Consider the following C code

#include <stdio.h>

int main()
{
    int a = 300;
    char *b = (char *)&a;
    *++b = 2;
    printf("%d ",a);

    return 0;
}

 

Consider the size of int is two bytes and size of char as one byte. Predict the output of the following code. Assume that the machine is a little-endian.

14 / 21

What is the output?

#include<stdio.h>

int main()
{
    int a;
    char *x;

    x = (char *)&a;
    a = 664;
    x[0] = 1;
    x[1] = 2;

    printf("%d\n",a);

    return 0;
}

 

15 / 21

Generic pointers can be declared with__________ .

16 / 21

What is the output?

#include<stdio.h>

int main()
{
    int a = 10;

    void *ptr = &a;

    printf("%d", *(int *)ptr);

    return 0;
}

 

17 / 21

What does the following statement mean?

//Declaration

int (*fptr)(void *);

 

18 / 21

When does the void pointer can be dereferenced?

19 / 21

What is the output?

#include<stdio.h>

int main()
{
    int a = 10;

    void *ptr = &a;

    printf("%d", *ptr);

    return 0;
}

 

20 / 21

Suppose that in a C program snippet, the following statements are used.

i) sizeof(int);

ii) sizeof(int*);

iii) sizeof(void*);

 

Assuming the size of the pointer is 4 bytes and the size of the int is also 4 bytes, pick the most correct answer from the given options.

21 / 21

The operator used for dereferencing or indirection is ____

Your score is

0%

Recommended Articles for you: