edited by
5,799 views

3 Answers

Best answer
13 votes
13 votes

Answer is 11

initial condition j = 1 and i =2

i/j>0.001 ..... j should be >2000

now j increases as 2

So 2n > 2000 i.e 2048

therefor n = 11

for n = 12.... i/j<0.001 so condition false and exits loop

selected by
1 votes
1 votes
Its very simple maths used here

i/j > 0.001 holds true

As you can see i=2 always and never changes , while the value of j is constantly changing in terms of 2^n.

2/2^n > 0.001

1/2^(n-1) > 0.001

2^(n-1) < 1000 holds true

it will fail when 2^(n-1)=1024 ,

hence n-1=10

n=11
0 votes
0 votes
Answer is D
Answer:

Related questions

8.2k
views
7 answers
8 votes
ajit asked Sep 2, 2015
8,231 views
What is the output of the following C program?#include<stdio.h void main(void){ int shifty; shifty=0570; shifty=shifty>>4; shifty=shifty<<6; printf("The value of shifty i...
560
views
1 answers
0 votes
TusharKumar asked Dec 22, 2022
560 views
can anyone explain how the for loop works here..?
330
views
2 answers
3 votes
GO Classes asked Apr 30, 2022
330 views
What will be the output of the following lines of code?int i = 0; int j = 0; char *s = "ceded"; while (s[i] != '\0') { j = j + s[i] - 'b'; i = i + 1; } printf("%d %d\n", ...
1.8k
views
1 answers
4 votes
amIndian asked Dec 17, 2017
1,831 views
Consider the following program fragment:int d = 0; int i,j,k; for(i=1; i<31; ++i) for(j=1; j<31; ++j) for(k=1; k<31; ++k) if(((i+j+k)%3) == 0) d=d+1; printf("%d",d);The n...