VARIABLES IN C PROGRAMMING | FULL INFORMATION

VARIABLES IN C PROGRAMMING 


A Variable is an identifier that is used to represent a particular type of information in a part of a program. We can see a Variable as a container that is used to store a value.


For e.g. int a;


Here we have created a variable named whose data type is an integer.


Use 'equal to the operator (=) to assign a value to a variable.


Rules for declaration of variables


1) Variable names must start with a letter or underscore.

2) The variables in C are case-sensitive. For eg name and NAME are two different variables.

3) No special symbol other than Underscore is allowed.

4) Variables can be constructed with digits or letters.

5) Some examples of variables are name, _age, etc.


Declaration and initialization of variables in C: -


* It is necessary to declare the variable before use.


* No memory is allocated to any variable at the time of declaration. Memory allocation is only when giving the definition of the variable.


* Variable initialization means assigning value to a variable.


C has three types of variables -


1) Local variable

2) Global variable

3) Environment variable


* The scope of the local variable is within the function itself.

* They cannot be accessed from outside the function and are declared inside the function.


Global variable: - The variables which are declared outside the function are called global variables. They are not limited to any function. Any function can access and modify global variables. Generally, global variables are written before the main function. 

AKASH TIMES

I AM AN ENGINEER BY PROFESSION BUT BLOGGER IS MY OLD DAYS DREAM TO CREATE MY OWN SITE FOR THOSE WHO ARE CURIOUS ABOUT MY BIRTHPLACE THEN I AM COMING FROM (INDIA). THE CURRENT CITY LIVES IN NAVI MUMBAI, INDIA

Post a Comment

IF YOU HAVE ANY PROBLEM PLEASE FELL FREE TO CONTACT US BY - AKASH TIMES

PREVIOUS POST NEXT POST