female_students Ratio = ------------------- male_studentsSince if female_students and male_students are declared as integers, the decimal part will be rounded off and its ratio will represent a wrong figure. Previous problem can be solved by converting locally one of the variables to the floating point as shown below.
The operator float converts the female_students to floating point for the purpose of evaluation of the expression.Ratio = (float) female_students / male_students
(type_name) expression