How to divide integers and get a float in C

前端 未结 2 633
余生分开走
余生分开走 2021-01-27 13:11

I\'m building a paragraph difficulty labeler by getting the number of words, sentences and letters.... I\'m trying to divide to integers and get a float for example ((let

2条回答
  •  悲哀的现实
    2021-01-27 13:35

    You could put 100.00 rather than 100 to tell the compiler to evaluate the expression as a floating point expression as follows:

    int num1 = 80;
    int num2 = 21;
    float L = (num1 * 100.00) / num2; // 100 -> 100.00
    

    It'll result:

    380.952393
    

提交回复
热议问题