C-C++ Defining a variable
Before you use a variable, you have to define it.
Variable definition (sometimes also called a variable declaration) is nothing more than letting the compiler know you will need some memory space for your program data so it can reserve some.
- To define a variable, you only need to state its type, followed by a variable name.
Syntax
<data type> <variable_name>;
Example
char mvExamScore; // This is called variable definition
Variable initialization
First define the variable, then initialize it with a value.
Example
char mvExamScore; // Variable definition
myExamScore = 25; // Variable initialization
Example
char mvExamScore = 25; // Other form of Variable definition