Initialization of a variable in C++ Programming language with Examples |
Initialization of a variable:
When a variable is declared, it contains garbage until you assign an initial value.
There are three ways to do this in C++:
- int number = 5; OR int number (5); OR int number {5};
- double doubleNumber = 1.0;
1) int firstNumber = 5, secondNumber=7, newNumber =8;
2) double firstNumber = 5.334556;
3) float area = 64.74;
4) double volume = 134.64534;
5) double distance = 45E12
6) char character ='h';
7) bool cond = false;
0 Comments