he following code finds out the factorial of a number. There is some error in it. Can you fix the bug?
1
#include
2
int main ()
3
{
4
long number;
5
std::cin>>number;
6
std::cout<< factorial (number);
7
return 0;
8
}
9
long factorial (long a);
10
{
11
for(int i=1;i<=a;i++)
12
fact=fact*i;
13
}
Answers
Answered by
0
Answer:
huh what do you mean by that?? I don't know
Answered by
1
#include <iostream>
int factorial (int);
int main ()
{
int number;
std::cin>>number;
std::cout<< factorial (number);
return 0;
}
int factorial (int a)
{int fact=1;
for(int i=1;i<=a;i++)
fact=fact*i;
return(fact);
}
Similar questions