Presentation of Programing
Presentation of Programing
Presentation of Programing
TYPE CASTING
example :
#include <stdio.h>
int main()
{
int a = 15, b = 2;
float div;
div = a / b; // Implicit type casting
printf("The result is %f\n", div);
return 0;
}
Output – The result is 7.000000
o Explicit Type Casting :-
Explicit type casting involves forcing the conversion
between data types.
You explicitly define the type conversion within the
program.
For example, when we need to change the data type of
a variable to get the correct output.
Example :
#include <stdio.h>
int main()
{
int a = 15, b = 2;
char x = 'a';
double div ;
div = (double)a / b; // Explicit type casting
x = x + 3;
printf("The result of Implicit typecasting is %c\n", x);
printf("The result of Explicit typecasting is %f", div);
return 0;
}
Output : The result of Implicit typecasting is ‘d’
The result of Explicit typecasting is 7.500000
THANK YOU