1

I'm trying to divide two int variables and get a float, but I don't know what the right way of doing it without losing any value.

I tried using double but its just messing it up

#include <stdio.h>

int main()
{
    int a, b;
    double c;
    a = 5;
    b = 2;
    c = a / b;
    printf("%lf", c);
//output: 2.000000
}

This should be 2.500000

0 Answers0