Storage Classes


  1. Where are the uninitialized global variables stored?









  1. View Hint View Answer Discuss in Forum

    Uninitialized global variables are not local to a function, their lifetime is throughout program execution and scope is throughout the file.

    Correct Option: D

    BSS is Block Started by Symbol.
    All uninitialzed global variables are stored into this segment,


  1. On freeing a dynamic memory, if the pointer value is not modified, then the pointer points to.











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    The same deallocated memory location



  1. Which of the following should be used for freeing the memory allocated in the following C code?
    #include <stdio.h>
    struct p
    {
    struct p *next;
    int n;
    };
    int main()
    {
    struct p *ptr1 = (struct ptr*)malloc(sizeof(struct p));
    ptr1->n = 1;
    ptr1->next = (struct ptr*)malloc(sizeof(struct p));
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    free(ptr1->next);
    free(ptr1);


  1. What will be the output of the following C code?
    #include <stdio.h>
    struct p
    {
    struct p *next;
    int n;
    };
    int main()
    {
    struct p *ptr1 = calloc(1, sizeof(struct p));
    ptr1->n = 1;
    ptr1->next = calloc(1, sizeof(struct p));
    printf("%d\n", ptr1->next->n);
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    0



  1. What will be the output of the following C code?
    #include <stdio.h>
    struct p
    {
    struct p *next;
    int n;
    };
    int main()
    {
    struct p* ptr1 = malloc(sizeof(struct p));
    ptr1->n = 1;
    ptr1->next = malloc(sizeof(struct p));
    printf("%d\n", ptr1->next->n);
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    Garbage value