in c++ PLEASE You will write a program that reads 2 integers from the user and calls 3 different functions to do the fol

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

in c++ PLEASE You will write a program that reads 2 integers from the user and calls 3 different functions to do the fol

Post by answerhappygod »

in c++ PLEASE
You will write a program that reads 2 integers from the user and
calls 3 different functions to do the following: void swapArgs(int
*, int *) function that takes 2 pointers to integers and swaps the
integers read in main(). void divideArgs(int *, int *) function
that takes 2 pointers to integers and stores the integer quotient
in the first pointer parameter and the remainder in the second
pointer parameter. void powerArgs(int *, int *) function that takes
2 pointers to integers, raises the first integer to the power of
the second integer, and stores the result in the first integer. You
may NOT use the pow() function to do this, you must use a loop to
calculate the result. Recall, any number raised to the 0 power is
1. If the power is a negative number, do not calculate any result.
See sample runs below. Create two integer variables in main(),
prompt the user for two integers, and pass their addresses to the
pointer parameters. If the user enters two zero’s, print a message
“No operations performed!” and end the program. Be careful to
notice where pointers and variable addresses are used - the idea of
this assignment is to practice writing code that uses pointers.
Output the values of the two integers entered from the user, and
their contents after the calls to the three functions. See sample
runs below.
Enter integer 1: 3
Enter integer 2: 17
Before call to swapArgs a: 3 b: 17
After call to swapArgs a: 17 b: 3
After call to divideArgs a: 5 b: 2
After call to powerArgs a: 25 b: 2
Goodbye!
Enter integer 1: 2
Enter integer 2: 10
Before call to swapArgs a: 2 b: 10
After call to swapArgs a: 10 b: 2
After call to divideArgs a: 5 b: 0
After call to powerArgs a: 1 b: 0
Goodbye!
Enter integer 1: -10
Enter integer 2: 3
Before call to swapArgs a: -10 b: 3
After call to swapArgs a: 3 b: -10
After call to divideArgs a: 0 b: 3
After call to powerArgs a: 0 b: 3
Goodbye!
Enter integer 1: 0
Enter integer 2: 0
No operations performed!
Enter integer 1: -2
Enter integer 2: -9
Before call to swapArgs a: -2 b: -9
After call to swapArgs a: -9 b: -2
After call to divideArgs a: 4 b: -1
After call to powerArgs a: 4 b: -1
Goodbye!
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply