What is Type Casting? Example of Type casting in C Language.

Leave a Comment

The process of converting one type of data into another type of data is referred as type casting.
For changing an integer to a float,
Z = float (x)/y

Where x and y are declared as integer type initially and z is declared as float type. Hence the above expression gives float value though x and y are declared as integers.

Example
main ( )
{
char ch;
ch=’A’;
printf(“ch=%c\n”,ch); /* ch=A */
printf(“ch=%d\n” Ch); /* ch=65 */
}

0 comments:

Post a Comment