As you probably know, a variable is a named location in memory that is used to hold a
value that may be modified by the program. All variables must be declared before they
can be used. The general form of a declaration is
type variable_list;
Here, type must be a valid data type plus any modifiers, and variable_list may consist of
one or more identifier names separated by commas. Here are some declarations:
int i,j,l;
short int si;
unsigned int ui;
double balance, profit, loss;
Remember, in C/C++ the name of a variable has nothing to do with its type.
Where Variables Are Declared
Variables will be declared in three basic places: inside functions, in the definition of
function parameters, and outside of all functions. These are local variables, formal
parameters, and global variables.
No comments:
Post a Comment