Question: make sure this code is in c++ and also it gives an answer for 0 i have found other code but doesn't work on 0

 make sure this code is in c++ and also it gives

make sure this code is in c++ and also it gives an answer for 0 i have found other code but doesn't work on 0 like sample 2

Exercise 3 The Factorial of a positive integer N is defined as: N! = N*(N-1)*(N-2)*...*1 1 for N> 0 N==0 For example for N=5, N!= 5*4*3*2*1 =120 Write a C++ program that asks the user to enter a positive integer N. The program then computes and prints the factorial of N (i.e., N!) using a while loop. Sample session (1): C: Microsoft Visual Studio Debug Console Enter a positive integer: 5 Factorial of 5 is 120 C:\Users\User\source epos\Project1\Debug\Project1.exe (process 5796) exited with code 0. Press any key to close this window Sample session (2): C Microsoft Visual Studio Debug Console Enter a positive integer: 0 Factorial of 0 is 1 C:\Users\User\source epos\Project1\Debug\Project1.exe (process 16660) exited with code 0. Press any key to close this window Sample session (3): C Microsoft Visual Studio Debug Console Enter a positive integer: -8 Invalid input C:\Users\User\source epos\Project1\Debug\Project1.exe (process 17040) exited with code 0. Press any key to close this window

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 Databases Questions!