MCQ Practice Single Best Answer Topic: Structure in C Language

Q What is the output of this C code?

    #include <stdio.h>
    struct student
    {
        char *name;
    };
    struct student s;
    struct student fun(void)
    {
        s.name = "newton";
        printf("%s\n", s.name);
        s.name = "alan";
        return s;
    }
    void main()
    {
        struct student m = fun();
        printf("%s\n", m.name);
        m.name = "turing";
        printf("%s\n", s.name);
    }

Question ID
#2633
Subchapter
Structure in C Language
Action
Choose one option below

Choose Your Answer

Click an option to check whether your answer is correct.

  • A newton alan alan
  • B alan newton alan
  • C alan alan newton
  • D Compile time error
Correct Answer: A

Explanation

None

Share This Question

Share this MCQ with your friends or study group.