- 1

Why this code doesn’t work ?(factorial)

What is problem with this code(factorial) https://code.sololearn.com/cb3y5047086H/?ref=app #include <iostream> using namespace std; int f(int a,int i) { int a; for(i=1;i<a;i++) a =a*i; return a; } int main() { int a,i; cin>>a; f(a,i); cout<<f(a,i); }

26th Apr 2020, 1:19 PM
Amirhossein Omidi yekta
Amirhossein Omidi yekta - avatar
2 odpowiedzi
+ 1
Amirhossein Omidi yekta you have duplicate questions?also you should learn the basic syntax or atleast learn to read the errors or you won't be able to understand anything as can be seen from the mistakes in this code:-)
26th Apr 2020, 1:36 PM
Abhay
Abhay - avatar
0
You are not initialising i. You don't have to pass it to the function. You can just pass the a value.
26th Apr 2020, 1:24 PM
Abirame Dhevendran
Abirame Dhevendran - avatar