Question: Data Structure and Algorithm Code . cppCode.txtScreenshot.jpg QuestionWrite a C + + program that calculates the factorial of a non - negative integer using recursion.

Data Structure and AlgorithmCode.cppCode.txtScreenshot.jpgQuestionWrite a C++ program that calculates the factorial of a non-negative integer using recursion. The program should take a user-provided integer, calculates its factorial and displays the answer.Requirements1. Prompt the user to enter an integer.2. If user enters a negative number, display Factorial is not defined for negative numbers.3. If user entered number is 0 or 1, return 1.4. If user enters a number greater than 1, then use recursion to calculate factorial.5. Display the factorial final result.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!