+1(978)310-4246 credencewriters@gmail.com
Select Page

Assignment 4 Functions and Arrays
Based on what you have learned so far, please make the following programs in C++.
1. Make a function named â€œshowMe()â€ to display your name and school year. After that, use any loop
statements to display them 100 times like below
2. Get one integer, and if it is an even number, display it as â€œEven Numberâ€. Otherwise, display it as
â€œOdd Numberâ€. Function declaration is as follows: void isEven (int even)
3. Write a function named â€œdouble calVolume(double radius)â€ that calculates the volume of the
sphere by receiving the radius of the sphere. The math formula to calculate the volume of the sphere
is as follows: V = (4*â„¼*radius3) / 3 where â„¼ is 3.14
4. Write a program that simulates a lottery. The program should have an array of five integers named
lottery and should generate a random number in the range of 0 through 9 for each element in the
array. The user should enter five digits, which should be stored in an integer array named user. The
program is to compare the corresponding elements in the two arrays and keep a count of the digits
that match. For example, the following shows the lottery array and the user array with sample
numbers stored in each. There are two matching digits (elements 2 and 4).
Lotter array:
7
4
9
1
3
2
9
7
3
User array:
4
The program should display the random numbers stored in the lottery array and the number of
matching digits. If all of the digits match, display a message proclaiming the user as a grand prize
winner.