codeGK
Code it ALL
C Variables - CodeGK
♦ C Variables

♣ About Variables

Variables, are allocation(initialization) of memory for Data Types.
Each variable has a specific Data Type associated with it.
Also the variable can be classified further on the basis of accessing property:-
  • Global Variable
  • Local Variable

♣ Example1: Global Variable in C

The variable which can be accessed from any part of the code is called Global Variable.
Note that the variable should be declared and initialized above of calling.
These variable are so-called having Global Scope, that is, the scope of the variable is not limited to any part of the code.
In this example, Global Variable is illustrated.
Example
Input:
Output:

♣ Example2: Local Variable in C

The variable which can be accessed from a particular part of the code is called Local Variable.
These variable are so-called having Local Scope, that is, the scope of the variable is limited to a particular part of the code.
In this example, Local Variable is illustrated.
Example
Input:
Output:
Prev_LessonNext_Lesson
C Variables