Unit 4 - Declaring Variables
All variables in a program must be declared prior to their use. The declaration takes the form:
Examples of variable declarations.
Int x, y, z;
Short small_number;
Long big_number;
Unsigned positive_number;
Char ch;
Float amount, rate;
Variables may be initialized by assigning constants to them either at the time of their declaration or at a later time.
Example of variable initialization and declaration
int m, n=10;
float rate, total = 0.0;
char response= ’n’;
char color{6}=’green’;
Examples of variable declarations.
Int x, y, z;
Short small_number;
Long big_number;
Unsigned positive_number;
Char ch;
Float amount, rate;
Variables may be initialized by assigning constants to them either at the time of their declaration or at a later time.
Example of variable initialization and declaration
int m, n=10;
float rate, total = 0.0;
char response= ’n’;
char color{6}=’green’;
No comments:
Post a Comment