Академический Документы
Профессиональный Документы
Культура Документы
First Program
Variables in C
Variables in C : Variable is used to store the values temporarily during the execution (runtime) of the program. Variables are allocated Memory Space (in RAM) depending on the data type. First we have to declare the needed variables in our program before actually using it. Declaring the variables doesnt guarantee that space is allocated in the Main Memory (RAM). The space is allocated during the execution (runtime) of the program.
Primitive data types int, float, double, char Aggregate data types Arrays come under this category Arrays can contain collection of int or float or char or double data User defined data types Structures and enum fall under this category
int - data type int is used to define integer numbers. { int Count; Count = 5; }
float - data type float is used to define floating point numbers. { float Miles; Miles = 5.6; } double - data type double is used to define BIG floating point numbers. It reserves twice the storage for the number. On PCs this is likely to be 8 bytes. { double Atoms; Atoms = 2500000; }
char - data type char defines characters. { char Letter; Letter = 'x'; }
Modifiers The three data types above have the following modifiers. short long signed unsigned The modifiers define the amount of storage allocated to the variable. ANSI has the following rules: short int <= int <= long int float <= double <= long double