Solved

Which Algorithm Segment Completes the Definition for an Iterative Version

Question 10

Multiple Choice

Which algorithm segment completes the definition for an iterative version of the factorial function?
Int factorial_i (int n) {
Int result = 1;
/** missing code inserted here */
__________
Return result ;
}


A) if (n == 0)
return 1;
else if (n > 0)
return n * factorial_i(n - 1) ;
else
B) if (n == 0)
return result;
else if (n > 0)
return n * factorial_i(n - 1) ;
else
C) for (int i = 1; i <= n; i++)
result *= i;
D) for (int i = 1; i <= n; i++)
n *= i;

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents