VARIABLES AND DATA TYPES IN C
#VARIABLE:-
Variable is the name given to the storage area or memory location.
Example:-
- int 🠊 used for storing Integer.
- char 🠊 used for storing Character.
Declared by writing type variable _name;
Initialized and Declared by type variable _name = value;
Example:-
1. int a = 4;
2. int a;
a = 4;
# RULES FOR DEFINING A VARIABLE IN C:-
1. Can contain alphabets, digits, and underscore(_)
Example:-
- int sparsh;
- int _sparsh;
2. A variable name can start with an alphabet & underscore only.
Example:-
- int 9sparsh; 🠊 Invalid
- int long; 🠊 Invalid
NOTE:-
The above shown example is an invalid because a variable cannot start with the number and it also cant take the name of any keyword.
3. It can't start with the digit.
4. No whitespace and Reserved keywordsd is allowed.
Example:-
- int Sparsh Bhardwaj; 🠊 Invalid
- int long; 🠊 Invalid
SOME EXAMPLES OF THE VALID VARIABLE NAMES ARE:--
- int sparsh;
- float sparsh123;
- char_sparsh56;
SOME EXAMPLES OF THE INVALID VARIABLE NAMES ARE:--
- $sparsh;
- int 79sparsh;
- char long;
#DATA TYPES:-
1. Basic data types are:-
- int;
- char;
- float;
- double;
- long;
2. Derived data types are:-
- Array
- Pointer
- Structure
- Union
NOTE:-
These are derived from the basic Data Types.
3. Enumeration Data type:-
- enum;
4. Void Data Type:-
- void
THANK YOU FOR READING THIS ARTICLE ON-
SPARSH BLOG
If you want to suggest any changes in the program please feel free to contact us in the comment section or you can reach us using Contact us Page.
0 Comments
If you want to give any suggestion regarding the post please feel free to Comment below-