Write and run a program that asks the user to enter a positiveinteger num, and t
ID: 3615274 • Letter: W
Question
Write and run a program that asks the user to enter a positiveinteger num, and then choose from the following menu using a switchstatement:1- To find factorial of num, where:
factorial(num) = num * num-1 * num-2 *…..* 2 * 1
2- To find the sum of odd numbers from 1 to num.
If the user enters a wrong choice, the program should display anerror message.
Sample output 1:
Enter a number : 7
Choose : 1: to find factorial of the number
2: to find sum of odd numbers from 1 to the number
2
The sum of odd numbers from 1 to 7 is 16
Press any key to continue
Sample output 2:
Enter a number : 10
Choose : 1: to find factorial of the number
2: to find sum of odd numbers from 1 to the number
3
Invalid choice
Press any key to continue
Explanation / Answer
Odd No. #include void main() { int n; for(inti=0;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.