Answers for "C access global variable same name"

C
0

C access global variable same name

// C Program to demonstrate that we can access a global
// variable if we have a local variable with same name
#include <stdio.h>
  
// Global variable x
int x = 50;
  
int main()
{
    // Local variable x
    int x = 10;
    {
        extern int x;
        printf("Value of global x is %d\n", x);
    }
    printf("Value of local x is %d\n", x);
    return 0;
}
Posted by: Guest on April-13-2022

Code answers related to "C"

Browse Popular Code Answers by Language