Difficulty: Easy
Correct Answer: 5040
Explanation:
Introduction / Context:This program demonstrates using an out parameter to pass a value from a method while also returning a computed result. The loop calculates a factorial.
Given Data / Assumptions:
Concept / Approach:Factorial of n is 1 * 2 * 3 * ... * n. Thus factorial of 7 is 5040.
Step-by-Step Solution:
Initialize s = 1.Loop j = 1 to 7: s = s * j.After loop: s = 5040.Return s; print 5040.Verification / Alternative check:Known value: 7! = 5040; quick multiplication confirms.
Why Other Options Are Wrong:
Common Pitfalls:Confusing the printed value with the out parameter i; the console prints the return value.
Final Answer:5040
Discussion & Comments