Loading, please wait...

Explicit Conversion

Explicit type casting is done manually, It doesn't perform itself. So, using this we can convert one type to another data type as required. This is done by casting operator ‘( )’ and data type and expression may be constant, variable or expression.

Typecasting in C is done in the following form:

(data_type) expression;

 

Example:

/*A C program to show implicit conversion */
#include<stdio.h>
int main( void )
{
int i = 20;
short s;

s = (short)i; // Explicit conversion

printf(“Explicit value is %d”, s);

getch();
}

 

Output:

 Explicit value is 20.