Question: Complete the following tasks. All code must be in one main.cpp file. Label the code for each task with a comment. All code must be

Complete the following tasks. All code must be in one main.cpp file. Label the code for each task with a comment. All code must be styled correctly.
Task 1
Declare an int named constant called SIZE and assign 5 to it in the same statement.
Task 2
Declare an int variable named x and initialize it to 0 in the same statement.
Task 3
Declare an int array called list. Use the SIZE constant from Task 1 for its size. Initialize all five elements to 0 in the same statement.
Task 4
Prompt the user to enter an integer and store the user's input in x.
Task 5
Prompt the user to enter five integers and store the user's input in the list array using a for loop.
Task 6
Define a function called sumArray below main. This function will have an int array as its one parameter. The function will return the sum of the elements in the array as an int. Place the function prototype above main.
Task 7
Write a cout statement that calls sumArray with list as its argument, outputting the string "sum =" followed by the value returned from sumArray.
Task 8
Define a function called squareX below main. This function will have one int parameter. The function will return the square of the int parameter. Place the function prototype above main.
Task 9
Write a cout statement that calls the squareX function with x as its argument, outputting the string "x squared =" followed by the square returned from squareX. Place the function prototype above main.
Task 10
Define a function called compareXToFive below main. This function will have one int parameter. This function will compare the value in the parameter to 5 and output one of three strings: less than 5, greater than 5, or equal to 5. You must use an if...else inside of the function to do this. Place the function prototype above main.
Task 11
Call compareXToFive with x as its argument.
Task 12
Define a function called printZeroToTen below main. This function will not have any parameters. This function will contain a while loop that outputs the numbers 0-10. The numbers must be on the same line separated by spaces. Place the function prototype above main.
Task 13
Call printZeroToTen.
Task 14
Define a function called printArray. This function will have an int array as its one parameter. The function will output the values in the array. The values must be on one line separated by spaces.
Task 15
Call the printArray function with list as its argument.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!