Variables In C

Prashant | Wed, 10 Jun, 2020 | 169

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

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.
  • void:

Rules to name a Variable

  1. Variable name must not start with a digit.
  2. Variable name can consist of alphabets, digits and special symbols like underscore _.
  3. Blank or spaces are not allowed in variable name.
  4. Keywords are not allowed as variable name.
  5. 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 −

type variable_name;

Here type must be some valid data type and varible name should follow the above given rules.

for example:- 

int    i, j, k;
char   c, ch;
float  f, salary;
double d;







Related Articles :- 

1Introduction And Getting Started With C

2Basic 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 ?

Leave a comment