12. Integer division in old programming languages¶
Oldest programming languages produce a complete result in integer division.
10/3
equals 3When calculating Fahrenheit to Celsius, I will need to modify my program a bit if I use C or Java.
12.1. Converting degrees using C¶
#include <stdio.h>
int main(void){
float F, C;
printf("Fahrenheit: ");
scanf("%f", &F);
C = 5.0 * (F - 32.0) / 9.0;
printf("Celsius: %2.1f\n", C);
}
You have attempted of activities on this page