-
Write a program that will read in 4 numbers and print out their average.
-
Write a program to read in a set of numbers and print out their average. The program will start by prompting the user for the number of numbers to be read in and will then prompt for the individual numbers with a prompt such as
Enter Number 23
to indicate to the user which data item is currently being entered. Do something special when prompting for the last number.
Note that there is no need to store all the individual numbers, it is sufficient to maintain a running total.
-
Modify the previous program to print out the largest and smallest number read in as well as the average. Also change the prompt to show the number of numbers still to be entered.
-
Write a program to prompt the user for an integer and calculate the sum of all the integers up to and including the input value. Print out the result.
-
Modify the previous program to use floating point arithmetic to add up the reciprocals of all the integers up to and including the input value.
-
Further modify the previous program to print out a list of reciprocal sums for every integer up to and including the input value.
I.e. print out the sum of the reciprocals of the integers up to and including 1, up to and including 2, up to and including 3 etc., etc.
-
Write a program to print out the integers from 40 to 127 in decimal, octal, hexadecimal and also print out the equivalent character.
-
Modify the previous program to list the values 4 to a line.
-
As a seasonal amusement some programmers like to print out a picture of a Chirstmas Tree looking like this.
*
***
*
***
*****
*
***
*****
*******
|
---+---
The tree consists of a series of tiers (three in this case) of increasing size. Write a program to produce such a display having prompted the user for the number of tiers.
You could try putting a few baubles on the tree (using o or O).
-
A year is a leap year if it is divisble by 4 unless it is a century year (one that ends in 00) in which case it has to be divisible by 400. Write a program to read in a year and report whether it is a leap year or not.