Recently MeroSpark is lunched with more features and services, now you can ask your question, sell your books, share your notes and many more. Visit https://www.merospark.com/signup/ now and create your account to take full advantage of MeroSpark.

Literals / Constants – Object Oriented Programming (OOP)

Download our Android App from Google Play Store and start reading Reference Notes Offline.

constantLiterals / Constants
Object Oriented Programming(OOP)
Third Semester | Second year
BSc.CSIT | Tribhuvan University (TU)

Literals or Constants
A number which does not change its value during execution of a program is known as a constant or literals. Any attempt to change the value of a constant will result in an error message. Once identifier is declared as constant at the time of declaration, its value can’t be changed during the execution of the program. A keyword ‘const’ is added to the declaration of an identifier to make that identifier constant. A constant in C++ can be any of the basic data types. Let us consider the following C++ expression:

const float Pi = 3.1415;
The above declaration means that Pi is a constant of float types having a value: 3.1415

Examples of some valid constant declaration are:
const int rate = 60;
const float Pi = 3.1415;
const char ch = ‘A’;

(Visited 171 times, 1 visits today)

Posted By : Digvijay | Comment RSS | Category : Third Semester
Tag :

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

Wordpress DMCA
Community | Toolbar | Android App | Founder/Developer : Hari Prasad Chaudhary | CSIT Portal Manager : Digvijay Chaudhary