Type conversionis that which converts one data type into another. E.g. converting a int into float, converting a float into double, etc. The type conversion is that which automaticallyconverts one data type into another.
When a user converts one data type into another then it is called as the type casting. Remember the type Conversion is performed by the compiler but a casting is done by the user. E.g.converting a float into int.
When a user converts one data type into another then it is called as the type casting. Remember the type Conversion is performed by the compiler but a casting is done by the user. E.g.converting a float into int.
//Program to demonstrate type casting
#include <stdio.h>
#include <conio.h>
void main()
{
int a=5, b=8;
float c = 0, d = 0;
clrscr();
c = a/b;
printf("\nc = %f \n",c);
d = (float)a/(float)b;
printf("\nd = %f \n",d);
}
#include <stdio.h>
#include <conio.h>
void main()
{
int a=5, b=8;
float c = 0, d = 0;
clrscr();
c = a/b;
printf("\nc = %f \n",c);
d = (float)a/(float)b;
printf("\nd = %f \n",d);
}
Post a Comment