-- advertisement --

Storage Classes

  1. Where are the uninitialized global variables stored?
    1. stack segment
    2. heap segment
    3. text segment
    4. BSS
  1. View Hint | View Answer | Workspace | Discuss In Forum | Report

    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,

    Report

  1. What will be the output of the program:-

    extern int i = 5;
    main()
    (
    int i=7;
    printf("%d",i);
    }
    1. 5
    2. compiler error
    3. 7
    4. garbage value
  1. View Hint | View Answer | Workspace | Discuss In Forum | Report

    variable declared with extern keyword has scope throughout the file, it is a global variable.
    variable declared within the function is local to the function in which it is declared.

    Correct Option: C

    printf function prints value of i, which is local to the function in which it is declared.

    Report

-- advertisement --