adplus-dvertising

Welcome to the Pointers and Arrays in C MCQs Page

Dive deep into the fascinating world of Pointers and Arrays in C with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Pointers and Arrays in C, a crucial aspect of C Programming. In this section, you will encounter a diverse range of MCQs that cover various aspects of Pointers and Arrays in C, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within C Programming.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Pointers and Arrays in C. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of C Programming.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Pointers and Arrays in C. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Pointers and Arrays in C MCQs | Page 1 of 53

Q1.
What is the output of this C code?
#include <stdio.h>
    int main()
    {
        char *p = NULL;
        char *q = 0;
        if (p)
            printf(" p ");
        else
            printf("nullp");
        if (q)
            printf("q\n");
        else
            printf(" nullq\n");
    }
Discuss
Answer: (a).nullp nullq
Q2.
What is the output of this C code?
#include <stdio.h>
    int main()
    {
        int i = 10;
        void *p = &i;
        printf("%d\n", (int)*p);
        return 0;
    }
Discuss
Answer: (a).Compile time error
Q3.
What is the output of this C code?
#include <stdio.h>
    int main()
    {
        int i = 10;
        void *p = &i;
        printf("%f\n", *(float*)p);
        return 0;
    }
Discuss
Answer: (d).0.000000
Q4.
What is the output of this C code?
#include <stdio.h>
    int *f();
    int main()
    {
        int *p = f();
        printf("%d\n", *p);
    }
    int *f()
    {
        int *j = (int*)malloc(sizeof(int));
        *j = 10;
        return j;
    }
Discuss
Answer: (a).10
Q5.
What is the output of this C code?
#include <stdio.h>
    int *f();
    int main()
    {
        int *p = f();
        printf("%d\n", *p);
    }
    int *f()
    {
        int j = 10;
        return &j;
    }
Discuss
Answer: (a).10
Discuss
Answer: (a).ptr is a pointer to integer, p is not
Q7.
What is the output of this C code?
#include <stdio.h>
    int main()
    {
        int *ptr, a = 10;
        ptr = &a;
        *ptr += 1;
        printf("%d,%d/n", *ptr, a);
    }
Discuss
Answer: (d).11,11
Discuss
Answer: (a).You cannot change the value pointed by ptr
Q9.
Which is an indirection operator among the following?

a.

&

b.

*

c.

->

d.

.

Discuss
Answer: (b).*
Q10.
Which of the following does not initialize ptr to null (assuming variable declaration of a as int a=0;
Discuss
Answer: (a).int *ptr = &a;
Page 1 of 53

Suggested Topics

Are you eager to expand your knowledge beyond C Programming? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!