NTA-UGC-NET 2021 Dec & 2022 June Paper-2
October 18, 2023GATE 2013
October 18, 2023Programming
Question 423 |
Consider the following pseudo-code fragment, where a and b are integer variables that have been initialized:
/* Pre-conditions: (a>1∧ a<b) */
/* Assume that overflow never occurs */
int x=0; int p=1;
while (p<b) {
p=p*a;
x=x+1;
}
When the while loop terminates, what will be the value of x in terms of a and b?
/* Pre-conditions: (a>1∧ a<b) */
/* Assume that overflow never occurs */
int x=0; int p=1;
while (p<b) {
p=p*a;
x=x+1;
}
When the while loop terminates, what will be the value of x in terms of a and b?
ab | |
ba | |
⌊logab⌋ /* ⌊ ⌋ means floor */ | |
⌈logab⌉ /* ⌈ ⌉ means ceil */ | |
None of the above |
Correct Answer: E
Subscribe
Login
0 Comments