Home » C Programming » Structures » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    struct Employee
    {
    char *Name;
    };
    struct Employee emp1;
    struct Employee function(void)
    {
    emp1.Name = "Ajit";
    printf("%s\n", emp1.Name);
    emp1.Name = "Prayag";
    return emp1;
    }
    void main()
    {
    struct Employee emp2 = function();
    printf("%s\n", emp2.Name);
    emp2.Name = "Vivek";
    printf("%s\n", emp1.Name);
    }
    1. Vivek
    2. Garbage value
    3. Ajit
      Prayag
      Prayag
    4. Compilation Error
    5. None of these
Correct Option: C

Ajit
Prayag
Prayag



Your comments will be displayed only after manual approval.