Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a program that will calculate the factorial of any user entered integer.

ID: 3579037 • Letter: C

Question

Create a program that will calculate the factorial of any user entered integer. For any positive integer n, the factorial is given as: n! = n ? (n-1) ? (n-2) ? …… ? 3 ? 2 ? 1. The factorial of 0 is 1. If a number is negative, factorial does not exist and this program should display error message. Sample output dialogues should look like these:

This is a C++ question using visual studio 2012 to answer it

please assist

6. Create a program that will calculate the factorial of any user entered integer. For any positive integer n, the factorial is given as: n! n (n-1) (n-2) 2 1. The factorial of 0 is 1. If a number is factorial does not exist and this program should display error message. Sample output dialogues should look like these: EnterAan integenER ERROR Factorial of a negative number doesn't exist Enter an integer 10 Factor iale 3628800

Explanation / Answer

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int i, number, factorial=1;
cout<<"Enter the any no. : ";
cin>>number;
if(number==0){// if number is zero
   cout<<"Factorial of 0 is 1 "<<endl;
}else if(number<=0){// if number is negative
cout<<"ERROR!!! Factorial of negative number doesn't exist "<<endl;
} else{ // other than 0 and negative numbers
   for(i=1;i<=number;i++)// multiplying the number of times of that number
   {
       factorial=factorial*i;
   }
   cout<<"Factorial: "<<factorial;
}
getch();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote