Computer Science, asked by reanspakrz41, 8 months ago

i need someone to explain this codes to me
long fact(int n);
int main()
{ for (int i=-1; i<20; i++)
cout << "fact(" << i << ") = " << fact(i) << endl;
}

long fact(int n)
{ if (n < 2) return 1;
long f=1;
for (int i=2; i <= n; i++)
f *= i;
return f;
}

Answers

Answered by Anonymous
4
  1. At statement 1 , function declaration is done
  2. At statement 2 , main function is defined
  3. after main function, long fact(int) is defined.
  4. at main function, fact() is called , inside for loop
  5. Which show the value of what long fact() function return.
  6. here on long fact() function, factorial of a number is calculated.

if not understand, then again asked it..I'll make you understand.

HAPPY CODING.

Similar questions