Write a program to demonstrate the use of Explicit conversion.
Dear,
This process is also called type casting and it is user defined. Here the user can type cast the result to make it of a particular data type. Here is a C program to demonstrate explicit type casting.
#include<stdio.h>
int main()
{ double x = 1.2;
// Explicit conversion from double to int
int sum = (int)x + 1;
printf("sum = %d", sum);
return 0;
}
This is done to take advantage of certain features of type hierarchies or type representations. It helps us to compute expressions containing variables of different data types.
Hope this helps!