Volume converter

From Programming In C

Exercise 2.2

In the UK we very much live in a hybrid world of imperial and metric quantities. This is especially so for volumes of liquids. We ask for a pint of beer and yet fill up our cars with litres of petrol. Write a short C program that converts litres into pints and fluid ounces. You will need to think carefully about integer division and remainders for this exercise.

Note that 1 litre = 1.76 pints and that 1 pint contains 20 fluid ounces.

When your program runs it should look something like (in bold font is what you type at the keyboard):

 Enter the number of litres: 4.82
 4.82 litres = 8 pints and 9.66 fluid ounces.

Return to the course summary

phy225: Course Details

general


compilers


2011-12 assessments


past exam papers

  • 2008-9 (http://physics-database.group.shef.ac.uk/exampapers/2008-09/PHY225%20LT.pdf)
  • 2009-10 (http://physics-database.group.shef.ac.uk/exampapers/2009-10/PHY225%20Exam%20Sem%201%202009-10.pdf)
  • 2010-11 (http://physics-database.group.shef.ac.uk/exampapers/2010-11/PHY225_10_11.pdf)