...
UGC NET CS 2014 Dec – paper-3
October 6, 2023
Programming-for-Output-Problems
October 6, 2023
UGC NET CS 2014 Dec – paper-3
October 6, 2023
Programming-for-Output-Problems
October 6, 2023

Programming-for-Output-Problems

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.
Correct Answer: D
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.
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!