Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Program : Write a complete C++ program that is made of functions main() and rShift(). The rShift() function must be a function without return with
Program: Write a complete C++ program that is made of functions main() and rShift(). The rShift() function must be a function without return with 6 parameters. rShift() should do following.
- Shift the first 4 formal parameters' value one place to right circularly and send the updated values out to the caller function, i.e. main. Furthermore, after calling this function with the first 4 actual parameters, say a1, a2, a3, a4, and these actual parameters should shift their value one place to right circularly as well. That is, a1 takes a2's value, a2 takes a3's value, a3 takes a4's value, and a4 takes a1's value.
- Assuming that first 4 formal parameters of rShift are n1, n2, n3, and n4, rShift should calculate maximum and average of n1, n2, n3, and n4, and send results back to caller function, i.e. main.
The main() function should do the following:
- Read four integers from the user with proper prompt and save them to four local variables.
- Call the rShift() function with 6 actual parameters.
- Receive all results, i.e. four shifted integers, plus maximum and average from rShift(). Then print these numbers with proper prompt text.
Note:
- No input and output with the user inside rShift() function. All input and output should be strictly limited inside main() function.
- Both statistics must be calculated with basic C++ flow control statements, and cannot be implemented by calling library functions such as max().
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started