ISRO | ISRO CS 2014 | Question 38
How many lines of output does the following C code produce?
float sum = 0.0;
while (i/j > 0.001)
Given, i = 2.0 and j = 1.0.
Since \”i\” is not changing, to satisfy condition:
i/j > 0.001
→ 2.0/j > 0.001
→ 2.0/0.001 > j
→ 2000 > j
Value of \”j\” should be less than 2000 to satisfy given condition. Value of \”j\” is increasing in power of 2, i.e., 2n. So,
2n > 2000
→ n > 10.9657
→ n = 11
So, after 11th line while loop will terminate.
Actual output is:
These are total 11 line.
So, option (D) is correct.
Quiz of this Question
Please comment below if you find anything wrong in the above post
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses
are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!