Lab 6

Part 1

Use the random() function to generate 50 integers between 1-100. Count the frequencies of odd numbers and even numbers that generate. You can consider to use two variables or an array of length 2 to store the frequencies. Then print the frequencies using printf().


Part 2

Use the random() function to generate 50 integers between 1-100. Count the frequencies of each number. Then use scanf() to retrieve the frequency of a specific number. Print the frequency of that number if the frequency is not 0, otherwise print "This number never appears". If the inquired number is out of range, print "The number is out of range". After that, check the frequency of all odd numbers. Report the percentages as well as the counts of the total odd numbers generated. The percentages should be shown with one digit after the decimal.

Answer the following questions:
(1) How do you initialize the counter array?
(2) What should be the length of the counter array? Notice that "0" is not in the range of the 50 generated integers.