Type Casting from int to float - C Data Type

C examples for Data Type:Type Cast

Description

Type Casting from int to float

Demo Code

#include <stdio.h> 

int main()//ww w . j av  a  2 s  . c o m
{ 
    int x = 12; 
    int y = 5; 
    float result = 0; 
    result = (float) x / (float) y; 

    printf("%f", result);
}

Result


Related Tutorials