Question: Problem A: a) Write a program that prompts the user for a positive number and then sums all the numbers from 1 up to the
Problem A:
a) Write a program that prompts the user for a positive number and then sums all the numbers from 1 up to the entered value. The program may not use a loop. Rather, it must use a recursive method to carry out the summing process. Here is an example of what a run of the program would look like:
Enter a positive number: 5 Result: 15
b) Sometimeswhenprogrammersgetboredorwanttohaveabitoffun, they add a harmless Easter Egg to their program. Modify the program from the previous exercise so that it prints a funny message when the user types a specific value. For example you might have the program print the message Answer to the Ultimate Question of Life, the Universe, and Everything when the user enters the number 42. The program should behave normally for all other supplied values.
Here are a couple of sample executions of the program:
Enter a positive number: 42 Answer to the Ultimate Question of Life, the Universe, and Everything Result: 903
Enter a positive number: 7 Result: 28
We are not encouraging you to put Easter Eggs in your programsthis is just an exercise.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
