#include <iostream>
#include <conio>
void main()
{
int n;
cout<<"Enter value of n:";
cin>>n;
if(n>=0)&&(n<=10)
{
{
if(n==0)
Zfactorial=1;
cout<<"/t/tThe value of Zfactorial for n"<<Zfactorial;
else(n>0)!!(n<11)
for(int n=0;n<11;n--)
Zfactorial=Zfactorial*(n);
cout<<"/t/tThe value of Zfactorial for n"<<Zfactorial;
}
else
cout<<"Invalid value of n";
continue
}
getch();
}
question
Professor Zoe has come up with the formula to calculate the Zfactorial of an integer. The symbol ‘#’ (a hash mark) indicates a Zfactorial defined as follows in Figure 1:
1 if n =0
n# =
[n * (n-1) * (n-2) * ... * 1] * n if 0 < n <=10
Figure 1: Zfactorial Definition
A program accepts an input n of type integer and computes the n Zfactorial. Before the computation, the program should checks the range of n is in between 0 and 10.
(0 <= n <= 10)
If the value of n is not in the range, the program will display an appropriate error message and input the value of n again until the user enter the valid value of n.