12. Integer division in old programming languages¶
Oldest programming languages produce a complete result in integer division.
10/3equals 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);
    }
12.2. Converting degrees using Python¶
Now we will convert the previous program to Python.
F = float(input("Fahrenheit: "))
C = 5.0 * (F - 32.0) / 9.0
print("Celsius: %2.1f" % C)
- 
On a scale from 1 (needs improvement) to 3 (excellent),
how would you rate this chapter?
 - 1
 - 2
 - 3
 
    You have attempted  of  activities on this page 
  
  
    
  
