Factorial of a number using loops

#include <iostream>

using namespace std;

int number,factorial;

int main(){

cout<<"enter number for which you want factorial "<<endl;

cin>>number;

factorial=number;

while(factorial!=1){
factorial--;

number*=factorial;

}
cout<<"the factorial of the number = "<< number<<endl;

}

Previous
Next Post »

Comments:

Disqus Shortname