logo

Crowdly

Browser

Add to Chrome

Consider the following program. Among the following statements, which ones are t...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Consider the following program. Among the following statements, which ones are true?

#include<stdio.h>

#define N 10

int main() {

int t[] = {1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1};

int l = 0, r = N - 1;

int cpt = 0;

while (l <= r) {

cpt++;

int m = l + (r - l) / 2;

if (t[m] == 1) {

l = m + 1;

} else {

r = m - 1;

}

}

printf("%d %d\n", l, cpt);

return 0;

}

More questions like this

Want instant access to all verified answers on moodle.myefrei.fr?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome