Saturday, September 12, 2020

in C, divide float by float and you will get a float

 if you have two integers that you want to divide, but do not want everything after the decimal point to be thrown away, you can type cast so that the computer treats the integers as floats, thereby ending up with more precise results

const int N;

int sum;

average = (float) sum / (float) N;



cs50, lec2



No comments:

Post a Comment