Unit 4 - Declaring Variables

Posted on Friday, May 7, 2010 by B[H] | 0 comments
Labels:

All variables in a program must be declared prior to their use. The declaration takes the form:

Photobucket

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