C examples for Function:Global Variable
Global variables are created and defined outside any function, including the main() function.
#include <stdio.h> void printLuckyNumber(); //function prototype int iLuckyNumber; //global variable int main(){ /*from w ww . j a v a 2 s .c o m*/ printf("\nEnter your lucky number: "); scanf("%d", &iLuckyNumber); printLuckyNumber(); } void printLuckyNumber() { printf("\nYour lucky number is: %d\n", iLuckyNumber); }