Variables in C (Basic)

Whenever you want to store some temporary data, then variables are used, like x=20, area=7.3. Here x and area are variable names. In C language variables must be declared before any function usage. (At top of the function). Format of variable declaration is data-type var; ex. int x;.

You can declare multiple variables in same statement. ex. int x,y,z;

We can also initialized variables during declaration part. ex. int x=20,y=23,z=40;

There are some basic rules for naming a variable

  • Variable/identifier name must not start with Digit.
  • Variable/Identifier name can contain only alphanumeric and _. No Other symbols rather than _ is allowed in variable name.
  • KeyWords (Reserved Words of C Programs- Those are in white color in Turboc3 IDE) are not allowed as a variable name.
  • Variable name can not have white space.
  • Uppercase and lower case are not same in variable names.

There are four storage classes of variables that will be discussed later .

Do not forget to subscribe to get advanced posts.

Leave a Reply

Your email address will not be published. Required fields are marked *

× How can I help you?