Type conversion in expression in c

Type conversion in expressions: -

  • Type conversion is a process of converting a variable's value from one data type to another data type.
  • There are two main types of conversion in C:

                1. Implicit type conversion.

                2. Explicit type conversion.

 

1) Implicit type conversion: -

  •  Implicit type conversion is a process of converting a variable's value from the lowest size of data type to the highest size of another data type.
  • This conversion is automatically done by the compiler without user intervention.
  • It is also known as type promotion or implicit type casting or automatic type conversion.
  • Hierarchy of data types: 

            Example: -


            Output: - 


2) Explicit type conversion: -

  • Explicit type conversion is a process of converting a variable's value from the highest size of datatype to the lowest size of another data type.
  • This conversion is manually done by the user by adding a cast operator (type) expression.
  • It is also known as type casting or explicit type casting or manual type conversion.

               Example: -


                Output: - 


Popular posts from this blog

operators in c programming

Variables in c

Cloud Storage and Local Storage: Applications in Business