Monday 22 April 2013

A programe to calculate factorial of a number

Description:

This program take a number from user as input and find its factorial automatically.

Code:


#include<iostream>
#include<conio.h>
#include<iomanip>
#include<math.h>
using namespace std;
int main()
{
       float a,b=1,c,i,f;
    cout<<"A programe to calculate factorial of a number"<<endl;
    xy:
    cout<<"Enter a number to calculate its factorial"<<endl;
    cin>>a;
    cout<<endl;
    i=a;
    while(i>=1)
    {
      b=b*i;
      i--;
      }
      cout<<"The factorial of the given number is"<<b<<endl;
      goto xy;
      getche();
      return 0;
      }


Output:


No comments:

Post a Comment