Structures


  1. Which of the following is an incorrect syntax to pass by reference a member of a structure in a function?
    (Assume: struct example{int num;} e;)











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: E

    None of these


  1. Which of the following structure declaration doesn’t require pass-by-reference?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: E

    None of these



  1. Which option is not possible for the following function call?
    func(&stru.num); //where stru is a variable of type struct and num is the member of the struct.











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Compiler can access entire structure from the function


  1. What will be the output of the following C code?
    #include <stdio.h>
    struct Example
    {
    int n;
    } e;
    void fun(struct Example);
    main()
    {
    e.n = 101;
    fun(e);
    printf("%d\n", e.n);
    }
    void fun(struct Example e)
    {
    e.n = 1;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    101



  1. What will be the output of the following C code?
    #include <stdio.h>
    struct option
    {
    int n1;
    int n2;
    };
    int main()
    {
    struct option opt1[] = {101, 97, 32, 91, 52, 91};
    struct option *ptr1 = opt1;
    int n1 = (sizeof(opt1) / 5);
    if (n1 == 3)
    printf("%d %d\n", ptr1->n1, (ptr1 + n1 - 1)->n1);
    else
    printf("False\n");
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: E

    False