Exercises
Exercises
Exercise 12270
Input two numbers and work out their sum, average and sum of the squares of the numbers.
Exercise 12271
Input and output your name, address and age to an appropriate structure.
Exercise 12272
Write a program that works out the largest and smallest values from a set of 10 inputted numbers.
Exercise 12273
Write a program to read a "float" representing a number of degrees Celsius, and print as a "float" the
equivalent temperature in degrees Fahrenheit. Print your results in a form such as
Exercise 12274
Write a program to print several lines (such as your name and address). You may use either several
printf instructions, each with a newline character in it, or one printf with several newlines in the string.
Exercise 12275
Write a program to read a positive integer at least equal to 3, and print out all possible permutations of
three positive integers less or equal to than this value.
Exercise 12276
Write a program to read a number of units of length (a float) and print out the area of a circle of that
radius. Assume that the value of pi is 3.14159 (an appropriate declaration will be given you by ceilidh -
select setup).
Your output should take the form: The area of a circle of radius ... units is .... units.
If you want to be clever, and have looked ahead in the notes, print the message Error: Negative values
not permitted. if the input value is negative.
Exercise 12277
Given as input a floating (real) number of centimeters, print out the equivalent number of feet (integer)
and inches (floating, 1 decimal), with the inches given to an accuracy of one decimal place.
Exercise 12278
Given as input an integer number of seconds, print as output the equivalent time in hours, minutes and
seconds. Recommended output format is something like
Exercise 12279
The first integer value represents a time of day on a 24 hour clock, so that 1245 represents quarter to
one mid-day, for example.
The second integer represents a time duration in a similar way, so that 345 represents three hours and
45 minutes.
This duration is to be added to the first time, and the result printed out in the same notation, in this case
1630 which is the time 3 hours and 45 minutes after 12.45.
Typical output might be Start time is 1415. Duration is 50. End time is 1505.