A function, getAverage generates 100 random numbers between 1 and 100.
It displays the average value.
Code this function and call it from a main driving program.
A kindergarten teacher is teaching animal words to her students. She is trying to explain that words have different lengths.
Implement a function, totalLength, that will allow the teacher to enter 5 different animal names. It will show the length of each word, and at the end, the total length of all of the words.
Test your program with the following words:
| cat | rabbit | elephant | crocodile | red-lipped batfish |
|---|
The final total should be 44.
A function, sumPairs, generates 10 random numbers in the range 1 to 10.
If each pair of numbers adds up to a number greater than 10, the first number is added to a total.
For example, if the following 10 numbers are generated:
| 3 | 8 | 1 | 1 | 3 | 4 | 8 | 5 | 2 | 1 |
|---|
then the program will produce a total of 11.
Implement this function.