Type casting is a way to convert a variable from one data type to another data type.
Syntax:
1 2 3 |
(type) expression; |
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
#include <stdio.h> int main() { int a,b; float sum; printf("Example of Type Casting\n"); printf("Enter any integer nos:"); scanf("%d",&a,&b); sum=a+b; printf("Sum: %f",sum); return 0; } |
Output
1 2 3 4 |
Example of Type Casting Enter any integer nos:Sum: 32766.000000 |