IEO Level 2- English Olympiad (SOF) Class 9 Coaching Programs

⏳ 🎯 Online Tests (2 Tests [50 Questions Each]): NTA Pattern, Analytics & Explanations

Click Here to View & Get Complete Material

Rs. 200.00

3 Year Validity (Multiple Devices)

πŸŽ“ Study Material (303 Notes): 2024-2025 Syllabus

Click Here to View & Get Complete Material

Rs. 450.00

3 Year Validity (Multiple Devices)

🎯 250 MCQs (& PYQs) with Full Explanations (2024-2025 Exam)

Click Here to View & Get Complete Material

Rs. 200.00

3 Year Validity (Multiple Devices)

Introduction to C ++ : Explicit Conversion: Constants and Variables

Explicit Conversion

It is also called type casting. It temporarily changes a variable data type from its declared data type to a new one. It may be noted here that type casting can only be done on the right-hand side of the assignment statement.

Initially variable salary is defined as float but for the above calculation it is first converted to double data type and then added to the variable bonus.

Constants

A number which does not charge its value during execution of a program is known as a constant.

  • Literals
  • Integer Numerals
  • Floating Point Numerals
  • Character and string literals

Any attempt to change the value of a constant will result in an error message. A constant in C ++ can be of any of the basic data types.

const qualifier can be used to declare constant as shown below:

The above declaration means that Pi is a constant of float types having a value 3.1415.

Examples of valid constant declarations are:

10 Variables

A variable is the most fundamental aspect of any computer language.

Illustration: 10 Variables
  • Variable are used in C ++ , where we need storage for any value, which will change in program.
  • It 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 values at different times during the execution of a program.
  • To understand more clearly, we should study the following statements:

For example, a variable Total of type float can be declared as shown below:

float Total.

Similarly, the variable Net can also be defined as shown below:

Examples of valid variable declarations are:

(i) int count.

(ii) int i, j, k.

(iii) char ch, first.

(iv) float total, Net.

(v) long int sal.