Variable Initialization

Variable Initialization

Variable is a location in the computer memory which can store data and is given a symbolic name for easy reference. The variables can be used to hold different values at different times during the execution of a program.
Declaration of a variable
Before a variable is used in a program, we must declare it. This activity enables the compiler to make available the appropriate type of location in the memory. 
float total;
You can declare more than one variable of same type in a single single statement

int x, y;
Initialization of variable
When we declare a variable it's default value is undetermined. We can declare a variable with some initial value. 
int a = 20;
The other way to initialize variables, known as constructor initialization, is done by enclosing the initial value between parentheses () :
For example:
int a (0);
Both ways of initializing variables are equivalent in C++.

ليست هناك تعليقات:

إرسال تعليق

شركنا الاراء ،،

جميع الحقوق محفوظه © مدونة فـاب

تصميم الورشه