###### UGC NET CS 2014 Dec – paper-3

October 6, 2023###### Programming-for-Output-Problems

October 6, 2023# Programming-for-Output-Problems

Question 35 |

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]

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]

( j=(x-1)!) ∧ (i>=x) | |

( j = 9!) ∧ (i =10) | |

(( j = 10!) ∧ (i = 10 )) V (( j = (x – 1)!) ∧ (i = x )) | |

(( j = 9!) ∧ (i = 10)) V (( j = (x – 1)!) ∧ (i = x )) |

Question 35 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.

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 35 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.

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.

Subscribe

Login

0 Comments