Variables in C language
Variables are nothing but the names of a memory location where we store some value. It can be easily manipulated by programmers that means its values can be easily replaced whenever needed. But keeping in mind that each variable in C has a specific type, which determines its size and by help of that memory allocaton is done.
Datatype of Variable
A variable in C language must be given a type, which defines what type of data the variable will hold.
It can be:
char: Can hold/store a character in it.
int: Used to hold an integer.
float: Used to hold a float value.
double: Used to hold a double value.
Rules to name a Variable
- Variable name must not start with a digit.
- Variable name can consist of alphabets, digits and special symbols like underscore
- Blank or spaces are not allowed in variable name.
- Keywords are not allowed as variable name.
- Upper and lower case names are treated as different, as C is case-sensitive, so it is suggested to keep the variable names in lower case.
Variable Definition in C
A variable definition tells the compiler where and how much storage to create for the variable. A variable definition specifies a data type and contains a list of one or more variables of that type as follows −
Here type must be some valid data type and varible name should follow the above given rules.
int i, j, k;
char c, ch;
float f, salary;
Related Articles :-
1. Introduction And Getting Started With C
2. Basic Of C Language
3. Why We Should Use C Language
4. Applications Of C Programming
5. Basic Rules For Writting C Program
6. Keywords In C Language
7. Comments In C Programming
8. Tokens In C
9. Difference Between Int Main And Void Main
10. C Processor And Macros
11. Variables In C
12. Types Of Variables In C
13. Difference Between Local And Global Variable
14. Difference Bwtween Auto / Extern / Static Variable
15. Constant In C
16. How To Access Global Variable Using Extern Keyword In C
17. Exit And Return Staterment In C
18. Print Float Value Upto N Decimals In C Programming
19. How To Print Multiline Message Using Single Printf In C Programming ?
20. What Value Returned By Scanf Function In C Language ?
21. What Value Is Returned By Printf And Scanf In C
22. What Do 'Lvalue' And 'Rvalue' Mean In C/C++?
23. Errors In C Programming ?