Variable in c is also called as Container to store the data
Variable name may have different datatypes to identify the type of value to stored.
Suppose we declare variable of type integer then it can store only integer values
A variable is a name given to the meory location whre the actual data is stored
Rules for Constructing variable in c
- Characters allowed: Underscore(_),Capital Letters(A-Z),Small Letters(a-z),and digits(0-9).
- Blank spaces and commas are not allowed.
- No special symbols other than Underscore (_) not allowed.
- First character should be alphabet or Underscore.
- Variable name should not be reserved keywords.
Variable declaration in c
- To declare is nothing but represent variable.
- Only variable name and its datatype is represent at declaration
- Declaration is used for identification of data type.
Examples of Declartion
int var;Here int is Integer datatype var is the variable name
float var; var is floating data type.
char var; var is here character data type.Types of Variable in C
- Local variable
- Global variable
Local Variables
- Local variable is having local scope.
- Local variable is accessible form function only or block in in which it is created.
- Local variable is given higher priority than the global variable.
Global variables
- Global variable is variable that is globally available.
- Scope of Global variable is throughout the program.[i.e all functions including main()]
- Global variable is also visible inside function,provides that it should not declared " High priority is given to local variable than Global
- Global variable can be accessed form any function
0 comments:
Post a Comment