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
Declare an int named constant called SIZE and assign to it in the same statement.
Task
Declare an int variable named x and initialize it to in the same statement.
Task
Declare an int array called list. Use the SIZE constant from Task for its size. Initialize all five elements to in the same statement.
Task
Prompt the user to enter an integer and store the user's input in x
Task
Prompt the user to enter five integers and store the user's input in the list array using a for loop.
Task
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
Write a cout statement that calls sumArray with list as its argument, outputting the string "sum followed by the value returned from sumArray.
Task
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
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
Define a function called compareXToFive below main. This function will have one int parameter. This function will compare the value in the parameter to and output one of three strings: less than greater than or equal to You must use an ifelse inside of the function to do this. Place the function prototype above main.
Task
Call compareXToFive with x as its argument.
Task
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 The numbers must be on the same line separated by spaces. Place the function prototype above main.
Task
Call printZeroToTen.
Task
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
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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
