Question 12964 – Operating-Systems
January 11, 2024Question 11110 – Computer-Networks
January 11, 2024Question 162 – Programming-for-Output-Problems
Consider the following C program
How many lines of output does this program produce?
Correct Answer: D
Question 35 Explanation:
→ Since there is one line of output for each loop, we need to determine the number of
times the loop executes. Since i is constant, we need to see the growth of j only.
→ Let the initial value of j be denoted by J1 and the subsequent values by Jn for n= 2, 3,… so that J denotes a progression of j. We see that Jn = 2Jn-1;
→ J1 = 2, which gives Jn = 2n-1;
n = 1, 2, …
→ The loop will execute as long as i/j=2.0/2n-1 >0.001 which gives n<3log210+2 (or) n<11.97.
→ Thus the loop will execute 11 times which is equivalent to say there will be 11 lines of output.
times the loop executes. Since i is constant, we need to see the growth of j only.
→ Let the initial value of j be denoted by J1 and the subsequent values by Jn for n= 2, 3,… so that J denotes a progression of j. We see that Jn = 2Jn-1;
→ J1 = 2, which gives Jn = 2n-1;
n = 1, 2, …
→ The loop will execute as long as i/j=2.0/2n-1 >0.001 which gives n<3log210+2 (or) n<11.97.
→ Thus the loop will execute 11 times which is equivalent to say there will be 11 lines of output.
0-9 lines of output
10-19 lines of output
20-29 lines of output
More than 29 lines of output
Subscribe
Login
0 Comments