Functions


  1. Which function is responsible for searching in the table? (For #define IN 1, the name IN and replacement text 1 are stored in a “table”)











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    lookup(s);


  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    struct S
    {
    char *name;
    struct S *next;
    };
    struct S s1, s2;
    s1.name = "Ajit Kumar Gupta";
    s1.next = NULL;
    ptrary[0] = &s1;
    strcpy(s2.name, s1.name);
    ptrary[1] = &s2;
    printf("%s\n", ptrary[1]->name);
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    Compilation Error

    main.c: In function ‘main’:
    main.c:12:9: error: ‘ptrary’ undeclared (first use in this function)
    ptrary[0] = &s1;
    ^~~~~~
    main.c:12:9: note: each undeclared identifier is reported only once for each function it appears in
    main.c:13:9: warning: implicit declaration of function ‘strcpy’ [-Wimplicit-function-declaration]
    strcpy(s2.name, s1.name);
    ^~~~~~
    main.c:13:9: warning: incompatible implicit declaration of built-in function ‘strcpy’
    main.c:13:9: note: include ‘’ or provide a declaration of ‘strcpy’



  1. What will be the output of the following C code?
    #include <stdio.h>
    struct M
    {
    char *name;
    struct M *next;
    };
    struct M *ptrary[10];
    int main()
    {
    struct M m1, m2;
    m1.name = "xyz";
    m1.next = NULL;
    ptrary[0] = &m1;
    strcpy(m2.name, m1.name);
    ptrary[1] = &m1;
    printf("%s\n", ptrary[1]->name);
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Segmentation fault


  1. What will be the output of the following C code?
    #include <stdio.h>
    struct Z
    {
    char *name;
    struct Z *next;
    };
    struct Z *ptrary[10];
    int main()
    {
    struct Z z;
    z.name = "Raj";
    z.next = NULL;
    ptrary[0] = &z;
    printf("%s\n", ptrary[0]->name);
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Raj



  1. What will be the output of the following C code?
    #include <stdio.h>
    struct B
    {
    char *name;
    struct B *next;
    };
    struct B *ptrary[10];
    int main()
    {
    struct B b;
    b->name = "Raj";
    b->next = NULL;
    ptrary[0] = &b;
    printf("%s\n", b->name);
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    Compilation Error

    main.c: In function ‘main’:
    main.c:11:10: error: invalid type argument of ‘->’ (have ‘struct B’)
    b->name = "Raj";
    ^~
    main.c:12:10: error: invalid type argument of ‘->’ (have ‘struct B’)
    b->next = NULL;
    ^~
    main.c:14:25: error: invalid type argument of ‘->’ (have ‘struct B’)
    printf("%s\n", b->name);