NCERT Computer: Chapter 7 – Introduction to C + + Part 7
Download PDF of This Page (Size: 243K) ↧
6 The sizeof operator
As we know that different types of variables, constant, etc. require different amounts of memory to store them.
The sizeof operator can be used to find how many bytes are required for an object to store in memory.
For Example 8
sizeof (char) returns 1
sizeof (int) returns 2
sizeof (float) returns 4
If k is integer variable, the sizeof (k) returns 2.
The sizeof operator determines the amount of memory required for an object at compile time rather than at run time.
7 The order of Precedence
The order in which the Arithmetic operators are used in a given 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
8 Type Conversion
The process in which one predefined type of expression is converted into another type is called conversion.
There are two types of conversion in C++.

Implicit conversion

Explicit conversion
1 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.