In C programming, a global variable is a variable that is declared outside of any function or block of code. Global variables are accessible from anywhere in the program, including within functions and blocks of code, and their values can be modified and accessed by any part of the program.
The basic syntax for declaring a global variable in C is as follows:
data_type variable_name ;
Here, the data_type specifies the data type of the variable, and the variable_name is the name of the variable. The variable is typically declared outside of any function, at the beginning of the program, before the main function.
Here is an example of a global variable being used in a program:
//Global Variable #include<stdio.h> void display(); int a=10; int main() { printf("\n Value of A : %d",a); display(); return 0; } void display() { a++; printf("\n Value of A : %d",a); }To download raw file Click Here
Value of A : 10 Value of A : 11
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions