My Report

C Array Test – 1


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. What will be the output of the following C code?

    #include <stdio.h>
    int main()
    {
        int ary[4] = {1, 2, 3, 4};
        int p[4];
        p = ary;
        printf("%d\n", p[1]);
    }

2. What are the different ways to initialize an array with all elements as zero?

3. What are the elements present in the array of the following C code?

int array[5] = {5};

4. Which of the following declaration is illegal?

5. An array of similar data types which themselves are a collection of dissimilar data type are ___________

6. What will be the output of the following C code?

    #include <stdio.h>
    int main()
    {
        int ary[4] = {1, 2, 3, 4};
        printf("%d\n", *ary);
    } 

7. What will be the output of the following C code?

    #include <stdio.h>
    int main()
    {
        const int ary[4] = {1, 2, 3, 4};
        int *p;
        p = ary + 3;
        *p = 5;
        printf("%d\n", ary[3]);
    } 

8. Comment on an array of the void data type.


 

Start practicing “1000 MCQs on C”, and once you are ready, you can take tests on all topics by attempting our “C Test Series”.

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.