Search code examples
cdivisioninteger-division

Quotient from integers in C


I want to get the result of a division of two integers. For example the integers 6 and 25. If I divide the integers I get 6/25 = 0 as the answer. I want the result to be 6/25 = 0.24. How can I do it?


Solution

  • It is as simple as

    #include <stdio.h>
    
    int main(int argc, char** argv)
    {
        printf("%.2f\n",(float)6/25);
    }