Hello everyone,i am a beginner in c++ and i am trying to write a program that outputs the factorial of a number in my own way,however i don't know why it's not working.Thanks for any help.This is the code:
Code:
#include<iostream.h>
#include<string>
using namespace std;
int main(void){
int fac;
int n;
string b;
cout<<"this program produces the factorial of a number"<<"/n";
cout<<"type an integer"<<"/n";
cin>>n;
if(n>0){
int c=1;
for(int a;n>=0;n=n-1){
a=n-1;
b=a*n;
c=b*c;
}
cout<<c;}
cin>>b;
}
Comment