Divides two given integers, display the result with 3 decimals. - C Data Type

C examples for Data Type:float

Description

Divides two given integers, display the result with 3 decimals.

Demo Code

#include <stdio.h>

int main (void)
{

    int i1, i2;/*from  ww w . ja v  a  2s.  com*/

    printf ("Enter two numbers: ");
    scanf ("%i%i", &i1, &i2);

    if (i2 == 0)
        printf ("the second number cannot be zero.");
    else
        printf ("%i / %i = %.3f", i1, i2, (float) i1 / i2);

    return 0;
}

Result


Related Tutorials