click on this link......

LinkGrand.com

Saturday, 30 March 2013

C variables

Variables in C
    A variable is a name given to an area in the memory of the computer where we can store a value.
    In C there are 3 main types of variables depending on the type of data that can be stored, they are:
1) Integer / Whole values
    To store whole numbers we use a datatype called "int". 
e.g.
 int a;
a is a variable that can store a whole number. It will occupy 2 bytes in memory.
2) Real values
    To store real numbers, or numbers with a decimal point, we use a datatype called "float".
e.g.
  float b;
 b is a variable that can store a real number. It will occupy 4 bytes in memory.
3) Single character values
    To store single characters, we use a datatype called "char"
.e.g.
  char c;
c is  a variable that can store a single character. It will occupy 1 byte in memory. The character has to be given within single quotes.

All variables that are to be used in a program must be declared immediately after main().

No comments:

Post a Comment