mardi 16 août 2022

This is giving inaccurate results for inputs

Program for finding factorial of a number is providing inaccurate output for the input >20.

#include <iostream>
using namespace std;
int main()
{

    unsigned int i,p;
    unsigned long int f=1;
    cout<<"Enter Number  : "<<endl;
    cin>>i;
    for (p=i;p>1;p-=2){
        f=f*p*(p-1);
    }
    cout<<"Factorial is \n"<<f;
}

Aucun commentaire:

Enregistrer un commentaire