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 ++ : The Size of Operator, the Order of Precedence and Type Conversion
The Size of Operator
- As we know that different types of variables, constant, etc. require different amounts of memory to store them.
- The size of operator can be used to find how many bytes are required for an object to store in memory.
For Example, 8
size of (char) returns 1
size of (int) returns 2
size of (float) returns 4
- If k is integer variable, the size of (k) returns 2.
- The size of operator determines the amount of memory required for an object at compile time rather than at run time.
The Order of Precedence
- The order in which the Arithmetic operators + , -, (βΉ, β, %) are used in each expression is called the order of precedence.
- The following table shows the order of precedence.
The expression in the following example is calculated from left or right.
Example 9
Type Conversion
The process in which one pre-defined type of expression is converted into another type is called conversion.
There are two types of conversion in C ++ .
- Implicit conversion
- Explicit conversion
Implicit Conversion
Data type can be mixed in the expression.
Example 10
- When two operands of different type are encountered in the same expression, the lower type variable is converted to the higher type variable.
- The following table shows the order of data types.
- The int value of b is converted to type float and stored in a temporary variable before being multiplied by the float variable c.
- The result is then converted to double so that it can be assigned to the double variable a.