C Programming: Simulate Program to Calculate xxx(17)

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 2K views
Maybe_Memorie
Messages
346
Reaction score
0

Homework Statement



Simulate the following program

#include <stdio.h>

int xxx (int n)
{
int count;

count = 0;

while ( n >=2)
{
n = n/2;
++count;
}

return count;
}

main()
{
printf( "xxx(17)=%d\n", xxx(17) );
}

Homework Equations





The Attempt at a Solution



Is this correct?

n, count
17 0
8 1
4 2
2 3
1 4

Return 4, 4 gets printed
 
Physics news on Phys.org