C examples for Function:Global Variable
Demonstrates local variables to hide the global variable
#include <stdio.h> int x = 1, y = 2; void demo(void); int main( void ) { printf("\nBefore calling demo(), x = %d and y = %d.", x, y); demo();/*www. j a v a 2 s .c o m*/ printf("\nAfter calling demo(), x = %d and y = %d\n.", x, y); return 0; } void demo(void) { /* Declare and initialize two local variables. */ int x = 8, y = 9; printf("\nWithin demo(), x = %d and y = %d.", x, y); }