edited by
924 views
4 votes
4 votes
# include < stdio.h >
main ( )
{

float total 0.0, q = 1.0, p = 2.0;
while (p/q> 0.001)
{
q = q + q ;
total = total + p/q ;
print f (“% f\n”, total) ;
}
}
Which one of the following is the integer that best approximates the last number printed ?

(A) 0

(B) 1

(C) 2

(D) 3
edited by

1 Answer

8 votes
8 votes

By looiking at first we may find that There is mistake in solution given by them but if we read question carefuuly than they have given that, best integer that approximates

Solution goes like this,

2/2+2/4+2/8+2/16+....+2/1024

Which is nothing but, 1+(1023/1024) = 1.9990234375  ~=2.00

P.S. My solution is so quick for now but I just want to show that significance of word 'Approximate' because I just read 'integer' and I written '1' as an answer.

Related questions

0 votes
0 votes
1 answer
3
smartmeet asked Feb 8, 2017
521 views
Which of the following statements is FALSE?(A) Each thread has own stack(B) Starvation implies deadlock(C) Smaller page size increases the page table size(D) User level p...
0 votes
0 votes
1 answer
4