How many lines of output does the following C code produce? #include<stdio.h>…

ISRO Scientist/Engineer SC 2014

How many lines of output does the following C code produce? 

#include<stdio.h>
float i=2.0;
float j=1.0;
float sum = 0.0;
main()
{
    while (i/j > 0.001)
    {
        j+=j;
        sum=sum+(i/j);
        printf("%f\n", sum);
    }
}
  1. A.

    8

  2. B.

    9

  3. C.

    10

  4. D.

    11

Attempted by 786 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…