October 6, 2023
October 6, 2023
October 6, 2023
###### Programming-for-Output-Problems
October 6, 2023
 Question 30
Consider the following C code segment: For the program fragment above, which of the following statements about the variables i and j must be true after the execution of this program? [!(exclamation) sign denotes factorial in the Solution]
 A ( j=(x-1)!) ∧ (i>=x) B ( j = 9!) ∧ (i =10) C (( j = 10!) ∧ (i = 10 )) V (( j = (x – 1)!) ∧ (i = x )) D (( j = 9!) ∧ (i = 10)) V (( j = (x – 1)!) ∧ (i = x ))
Question 30 Explanation:
As per code segment,

Step-1: The ith loop will compute from value 1 to 9. If the condition is true, then it computes j=j*i statement.
Step-2: The statement j=j*i is nothing but calculating 9!. If the condition fails automatically while loop will be terminated. It means maximum we can execute 9 values.
Step-3: when x becomes 10 then maximum I value will be 9. So, we can calculate up to 9!
And I become 10 then it terminates the condition.
Question 30 Explanation:
As per code segment,

Step-1: The ith loop will compute from value 1 to 9. If the condition is true, then it computes j=j*i statement.
Step-2: The statement j=j*i is nothing but calculating 9!. If the condition fails automatically while loop will be terminated. It means maximum we can execute 9 values.
Step-3: when x becomes 10 then maximum I value will be 9. So, we can calculate up to 9!
And I become 10 then it terminates the condition.