what is the output of this program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • divya ramprasad
    New Member
    • Jan 2014
    • 5

    what is the output of this program

    Code:
    Q1.What will be output of the following c program?
    #include<stdio.h>
    static num=5;
    int num;
    extern int num;
    int main(){
    printf("%d",num);
    return 0;
    }
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Have you compiled it to see what it does?

    Comment

    • divya ramprasad
      New Member
      • Jan 2014
      • 5

      #3
      i compiled....its coming 55...

      Comment

      • parvathireddy
        New Member
        • Jan 2014
        • 8

        #4
        I got output as 5 after solving




        "The static storage class is used to declare an identifier that is a local variable either to a function or a file and that exists and retains its value after control passes from where it was declared. This storage class has a duration that is permanent. A variable declared of this class retains its value from one call of the function to the next. The scope is local. A variable is known only by the function it is declared within or if declared globally in a file, it is known or seen only by the functions within that file. This storage class guarantees that declaration of the variable also initializes the variable to zero or all bits off.






        The extern storage class is used to declare a global variable that will be known to the functions in a file and capable of being known to all functions in a program. This storage class has a duration that is permanent. Any variable of this class retains its value until changed by another assignment. The scope is global. A variable can be known or seen by all functions within a program. ."

        Comment

        Working...