Open In App

C | Structure & Union | Question 1

Like Article
Like
Save Article
Save
Share
Report issue
Report

Choose the correct output from the options given below:

C




#include‹stdio.h›
int main()
{
    struct site
    {
        char name[] = \"GeeksQuiz\";
        int no_of_pages = 200;
    };
    struct site *ptr;
    printf(\"%d \", ptr->no_of_pages);
    printf(\"%s\", ptr->name);
    getchar();
    return 0;
}


(A)

200 GeeksQuiz

(B)

200

(C)

Runtime Error

(D)

Compiler Error



Answer: (D)

Explanation:

When we declare a structure or union, we actually declare a new data type suitable for our purpose. So we cannot initialize values as it is not a variable declaration but a data type declaration.


Quiz of this Question
Please comment below if you find anything wrong in the above post


Last Updated : 04 Feb, 2013
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads