1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Please explain the output

Discussion in 'C++' started by techme, Mar 21, 2010.

  1. techme

    techme New Member

    Joined:
    Feb 15, 2010
    Messages:
    86
    Likes Received:
    0
    Trophy Points:
    0
    Code:
    #include<stdio.h>
    #include<conio.h>
    int x=40;
    int main()
    {
    int x=20;
    printf("%d\n",x);
    return(0);
    }
     
  2. pankaj.sea

    pankaj.sea New Member

    Joined:
    Apr 6, 2009
    Messages:
    461
    Likes Received:
    13
    Trophy Points:
    0
    Occupation:
    Web Developer
    Location:
    Kolkata
    Home Page:
    the result will be 20;

    and the reason is whenevr there is a conflict between local variable & global variable it is the local variable that gets the priority...
     

Share This Page