Rule for declaring variable in C language

                                     Declaring variable in C:- 

1.  variable name should be continue there can not be any space in the variable name. If saperater is needed we may use underscope .


int Roll No;  ⇒ not allowed 
int Roll-No;  ⇒ not allowed 
int Roll_No;  ⇒ allowed 

 2.  Reserved words or keywords are not allows in variable name . Reseved word are those word which already have a meaning in C language .

int  if ;  ⇒ not allowed
int  while ;  ⇒ not allowed 
int  WHILE ;  ⇒ allowed 

3.  special charecter are not allowed in variable name .only one special charecter are allows that is underscope .

int Roll No;  ⇒ not allowed 
int Roll-No;  ⇒ not allowed 
int Roll_No;  ⇒ allowed

4.  variable name must start from either alphabet or underscope .

int Roll12 ;  ⇒ allowed 
int R1,R2,R3 ;  ⇒ allowed 
int _Roll ⇒ allowed 
int 1Roll ⇒ not allowed 

 

No comments

Powered by Blogger.