Home » , , » Definition And Rules To Write Variables

Definition And Rules To Write Variables

Written By Unknown on Sunday, October 6, 2013 | 4:24 AM

Definition : A variable is an identifier that represent a single data item like a numerical quantity or a character constant.Watch the program below :

1.#include<stdio.h>
2.#include<conio.h>
3.main()
4.{
5.int a,b,c;
6.char d;


In this program a,b and c are integer type variables and d is a character type variable.So we can easily say a,b and c will represent an integer valued quantity and d will represent a single character.


Rules To Write Variables : A programmer can use a variable name as the way he or she want but it should maintain the format mentioned below :

1. Programmer can use the mixed value of upper case alphabet ( A........Z ),Lower case alphabet ( a......z ) or Underscore ( _ ) to write a variable.

2.Variable name must start with an alphabet like ( A.....Z ) or ( a....z ).Some compiler also support underscore( _ ) first.

3.According to ANSI a variable name could contain up to 31 Character.

4.We can not use C-Keyword as a variable name.

5.Uppercase ( A.....Z ) and Lowercase ( a.....z ) are different in "C" so here "Sum" and "sum" are two different variable.

6.We can't place any "White Space" in a variable name like "SHU VO".It wll be "SHUVO"


Examples : 

Valid Variable Names :
                                       1.Shuvo
                                       2.S11
                                       3.SHAKHAWAT
                                       4.A_H_A_M_E_D

Invalid Variable Names:
                                      1.sh uvo
                                      2.0 43
                                      3.[ABC]
                                      4.(Ahamed)
                                      5.%S
                                      6.#shakhawat#

NOTE : 
Some character we can't use as a variable name like #, (, {, [ etc.

Share this article :

Post a Comment

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Learn Programming - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger| Distributed by Rocking Templates