Tuesday, 29 March 2016

Write a program to calculate the factorial of a given number in c++ language.

//WAP to calculate the factorial of a given number in c++ language.
#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();

int i,fact=1,n;
cout<<"enter number to find its factorial"<<" ";
cin>>n;
for(i=2;i<=n;i++)
{
fact=fact*i;
}
cout<<"factorial of nos is"<<fact;
getch();
}

output:-

                 

 

No comments:

Post a Comment