Functions and Recursions – Arithmetic – Problem #2
IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive
Problem Statement
Write a function named convertRealNumber(.) which converts a string representing a real number in the decimal format followed by a space and its unit (either in cm or in ft), into a floating point number in meter. For example, “123.25 cm” is converted as 1.2325, and “3.5 ft” as 1.0668. Write a program to read N (to be read first) strings denoting measurements of length in the above format and each given in a separate line. The program computes the maximum, minimum and average lengths in meter. Run the program with the following input data set: (i) N=5 2.54 cm 3.78 ft 17.85 cm 25.4 cm 5.6 ft (i) N=10 12.54 cm 13.78 ft 178.85 cm 235.4 cm 54.6 ft 12.4 cm 8.9 ft 73.4 cm 125.8 cm 29.45 ft