2.3 CONSTANTS AND VARIABLES DECLARATIONS
The most basic element of a program is a variable. As the name suggests, its value can be varied. Every variable has to be declared before its use. The declaration of a variable takes the following form:
<type> <variable name> ;
A typical example being
int mymarks ;
At this point in a program, a memory is assigned to this variable. As memory contains the arbitrary value, it is a good idea to initialize a variable at the time of declaration.
int mymarks =99;
If there are any variables of the same type, we can combine the declaration as shown below:
int i, j, k;
When we initialized the variable, we used a quantity 99. It is a constant quantity. In correct grammatical term, it is called a literal. Let us ...
Get Object Oriented Programming with C++, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.