(C++ EXPERIMENT NO 6
“Write a program to read a number and find its factorial using a
function
Algorithm
+ Step form algorithm
> START
> Indicate the user to enter the two numbers by displaying a suitable
sentence.
> Wait for the user to enter the number.
> Calculate the factorial using non recursive function
> Display the factorial with a suitable sentence.
> STOP
+ Pseudo form algorithm :
main() funtion
> 1. START
> 2. PRINT’Enter a number’;
> 3. INPUT a
> 4, fact = CALL factorial (arguments:a )
> 5. PRINT fact
> 6. STOP.
factorial ( parameters : a)
> 1. START.
> 2.1= 1, fact=
> 3. IF i> a, THEN GOTO step 7.
> 4, fact = fact’t
>5.t=te
> 6. GOTO step 3.
> 7. RETURN (fact )Program:
INivek bade
JIRoll no AQT
#include
using namespace std;
int main ()
{
int a.factorial;
int fact(int a);
cout<<"Enter a number"<>a;
Factorial= fact(a);
cout<<"Factorial of “<