Sunday, February 1, 2009

Constants and Variables


The alphabets, numbers and special symbols when properly combined form constants, variables and keywords. A constant is an entity that does not change.

Variables:
A variable is an entity that may change it value. In any program we typically do lots of calculations. The results of these calculations are stored in computer memory locations. To make the retrieval and usage of these values we give names to the memory locations. These names are called variables.

Keywords:
A keyword is a word that is part of C Language itself. These words have predefined meanings and these words cannot be used as variable names.

C Keywords

char

signed

break

for

auto

const

sizeof

case

if

extern

double

struct

continue

goto

register

enum

typedef

default

return

static

float

union

do

switch

volatile

int

unsigned

else

while

long

void

short



Types of Variables
There are two main types of variables in C: numeric variables that hold only numbers or values, and string variables that hold text, from one to several characters long.

Basic fundamental data types in C Language
Name
Description
Size
Range
char
Character or small integer.
1byte
signed: -128 to 127
unsigned: 0 to 255
short int
Short Integer.
2bytes
signed: -32768 to 32767
unsigned: 0 to 65535
long int (long)
Long integer.
4bytes
signed: -2147483648 to 2147483647
unsigned: 0 to 4294967295
bool
Boolean value. It can take one of two values: true or false.
1byte
true or false
float
Floating point number.
4bytes
+/- 3.4e +/- 38 (~7 digits)
double
Double precision floating point number.
8bytes
+/- 1.7e +/- 308 (~15 digits)
long double
Long double precision floating point number.
8bytes
+/- 1.7e +/- 308 (~15 digits)


For More Tutorials c tutorial



0 Comments: