0
Why this code go wrong??
3 Antworten
+ 2
Your code has many errors, i guess this is what you wanted to do:
https://code.sololearn.com/c48vb94aBIXM/?ref=app
+ 1
#include <iostream>
using namespace std;
int fact(int); //protype
int main() {
int n;
cout<<"enter value n = ";
cin>>n;
cout<<n;
int factorial=fact(n); //you miss some semicolons
cout<<"factorial = "<<factorial<<endl;
return 0;
}; //and this semicolons too.
int fact(int n) //you have to indicate the value you send to the function
{
int i,f=1;
for(i=1;i<=n;i++)
f=f*i;
return f; //this is the value you need to optain from the function.
};
0
great