Dorsa R.

asked • 02/03/21

please someone explain what this code do :

void bin(int x, int value)

{

if(x == 0)

return;

bin(x / 2, value - 1);

if(x % 2)

printf("%d ", value);

}

int Pow(int a, int b)

{

int d = 1;

for(int i = 1; i <= b; i++)

d *= a;

return d;

}

int main()

{

int n;

scanf("%d", &n);

for(int i = Pow(2, n) - 1; i >= 0; i--)

{

printf("{ ");

bin(i, n);

printf("}\n");

}

}

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.