Sunday, November 21, 2010

VARIABLES AND CONSTANTS IN C

What is a variable?? Why do we use variables??

Variable is data holder, in which we can store some data and we can modify that data later in the program.

In C programming before we store any data in a variable we need to declare that variable.

declaring a variable:
declaring a variable means telling the compiler that what type of values you want store in that variable.

datatype variablename ; // declaring a variable 

In C we have 4 types of Data Types:
1. int -  for integer values
2. float - for floating points
3. double - for long floating points such as scientific values
4.char  - for characters

declaring variables example: 

int a;  // tells the compiler that a is a integer type variable in which you want to store integer value.

float f; //

double d;

char c; 

once you declare the variables you can store actual values in those variables.

As I told you variable is data holder. so once you declare any variable C compiler will allocate memory depending on the specified data type.

int a; when do you this one C compiler will allocate 4 bytes of space for this variable called a.

its like this  a
                    

No comments:

Post a Comment