• edited by
970 views
1 1 vote

How many times does the while loop gets executed if the following function is called as $f(120,13)?$ 

f(m,n) { ans := 1 
while (m - n >= 0) { 
ans := ans * 2 
m := m - n 
} 
return(ans)
}

 

2 Answers

Position:
Show:

Related questions

0 0 votes
3 3 answers
1.1k
1.1k views
nabadeep asked Apr 27, 2017
1,134 views
what does following code mean if j=0 and a and b are two character pointers to two strings: while(a[j]&&b[j])
3 3 votes
1 1 answer
1.0k
1.0k views
Sourabh Kumar asked Jul 20, 2016
1,013 views
What is the output of the following program?#include<stdio.h void main() { int n=3, i=0; do { n=n++; i++; } while(i!=3); printf(“%d\n”, n); }
1 1 vote
1 answers 1 answer
5.4k
5.4k views
thehobo03 asked Jun 4, 2015
5,353 views
Assuming n>2 A() { while(n>1) { n = n/2; } }
1 1 vote
2 answers 2 answers
979
979 views
gopal_gate asked Jul 29, 2023
979 views
In the picture below:Can anyone explain to me why ‘while’ loop starting from 2 but in the case of ‘for’ loop it is starting from 1 (although i++ is available for both in ...