Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

what do i need to do to fix my code so the unit test and compare output work? in c++ please. 5.12 Factorial of an

what do i need to do to fix my code so the unit test and compare output work? in c++ please.
image text in transcribed
image text in transcribed
image text in transcribed
5.12 Factorial of an inputted integer Write a recursive function called factorial) to return the factorial of an integer that was inputted from keyboard The printing of output will be done in the main function The factorial of nis n' which is given by nie-7)(n-2) 2*1 Hence the factorial of 5 is 5X4X3X2X1 = 120. Similarly, the factorial of 4 is 4X3X2X1 = 24 ExIf the input is 5 the output is The factorial of 5 s 120 main.cpp 8 1 #include 2 using namespace std; 3 4 int factorial(int value) { 5 if(value > 1) 6 return value factorial(value - 1); 7 else return 1; 9) 10 11 int main() { 12 int num; 13 cin >> num; 14 15 cout Input 0 Your output The factorial of 0 is 1 4. Compare output 272 Input 1 Your output The factorial of 1 is 1 5. Unit test 073 Tests factorial) correctly to return factorial of inputted value Could not find valid return type for test Passed(). must be one of bool, int, float, or double 6. Compare output 071 Your output The factorial of 0 1 1 Expected output This test case should produce no output

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions