Write a Program in C++ to find the factorial of any positive integer number.

Write a Program in C++ to find the factorial of any positive integer number.

# include<iostream.h>
# include<conio.h>
void main ()
{
int num,fact =1, i;
clrscr();
cout<<"Enter a number\n";
cin>>num;
for(i=1;i<=num;i++)
   fact=fact*i;
cout<<"factorial of " << num <<" is " << fact;  
getch();
}

Output--

Enter a number
7
factorial of 7 is 5040



1 Comments

Post a Comment

Previous Post Next Post