Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. You are to write a program utilizing reference parameters. Your program should have
  2. the following four functions: menu, sum, power, gcd.
  3. Your program should first call menu, and display the options for your program – to find
  4. the power of x raised by y; the max power x can be without exceeding y, and printing out
  5. a number backwards. The choice is sent back via reference parameter (so it should be an
  6. argument). Reuse/recycle your menu function from Assignment 8.
  7. Next, your program should prompt for value(s) and then will perform the calculations for
  8. power, maxPower, or backwards (which is just printing out the number in reverse). The
  9. functions power and maxPower have return type int, while backwards has a return type of
  10. void. The power function will have two arguments: the number to raise and the power to
  11. raise the number to; the maxPower function will have two arguments: the number to
  12. raise and the number not to exceed; and backwards has one argument, the number to print
  13. out in reverse.
  14. Your program should print out the result to the screen. Last, your program should ask the
  15. user to select an option from the menu of four choices.
  16. One other note: each of the functions must solve its calculation/output recursively
  17. (see Ch. 6).
  18. Brief descriptions:
  19. Power: the power of x raised by y
  20. Power(3,4) = 3*3*3*3 = 81
  21. maxPower: the power of x raised by ? not to exceed y
  22. maxPower (2, 31) = 4
  23. maxPower(5, 125) = 3
  24. backwards(123456789) prints out 987654321
  25. Sample run:
  26. 1) Find the power of x raised by y.
  27. 2) Find the maximum power of y that does not exceed x.
  28. 3) Print out a number backwards.
  29. 4) Quit
  30. 2
  31. Enter the number to raise: 5
  32. Enter the number not to exceed: 624
  33. Result: 3
  34. 1) Find the power of x raised by y.
  35. 2) Find the maximum power of y that does not exceed x.
  36. 3) Print out a number backwards.
  37. 4) Quit
  38. 1
  39. Enter the number to raise: 2
  40. Enter the power to raise to: 8
  41. Result: 256
  42. 1) Find the power of x raised by y.
  43. 2) Find the maximum power of y that does not exceed x.
  44. 3) Print out a number backwards.
  45. 4) Quit
  46. 3
  47. Enter the number: 90210
  48. Result: 01209
  49. 1) Find the power of x raised by y.
  50. 2) Find the maximum power of y that does not exceed x.
  51. 3) Print out a number backwards.
  52. 4) Quit
  53. 3
  54. Enter the number: 37419
  55. Result: 91473
  56. 1) Find the power of x raised by y.
  57. 2) Find the maximum power of y that does not exceed x.
  58. 3) Print out a number backwards.
  59. 4) Quit
  60. 4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement