Explicit Casts
Manual conversions.
What Is a Cast
A cast explicitly converts a value to another type using (type)value. It tells the compiler exactly what you want.
#include <stdio.h>
int main(void) {
double d = (double)5;
printf("%.1f\n", d);
return 0;
}Forcing Real Division
Cast one operand to double so division keeps the fractional part.
#include <stdio.h>
int main(void) {
int a = 7, b = 2;
double r = (double)a / b;
printf("%.2f\n", r);
return 0;
}