I need help on this.can someone help me tell me what the code is talking about and how to tackle this problem ...the code is suppose to output this .............
[OUTPUT]
Sample outputs
$ a.out
Enter a number at most equal to 1023: 0
Cycling through {}
yields {}.
$ a.out
Enter a number at most equal to 1023: 4
Cycling through {2}
yields {3}.
$ a.out
Enter a number at most equal to 1023: 512
Cycling through {9}
yields {0}.
$ a.out
Enter a number at most equal to 1023: 5
Cycling through {0, 2}
yields {1, 3}.
$ a.out
Enter a number at most equal to 1023: 530
Cycling through {1, 4, 9}
yields {0, 2, 5}.
$ a.out
Enter a number at most equal to 1023: 85
Cycling through {0, 2, 4, 6}
yields {1, 3, 5, 7}.
$ a.out
Enter a number at most equal to 1023: 408
Cycling through {3, 4, 7, 8}
yields {4, 5, 8, 9}.
$ a.out
Enter a number at most equal to 1023: 682
Cycling through {1, 3, 5, 7, 9}
yields {0, 2, 4, 6, 8}.
[/OUTPUT]
This is the code .
Code:
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
int cycle(int);
void display_set_coded_by(int);
int main(void) {
int n;
printf("Enter a number at most equal to 1023: ");
scanf("%d", &n);
printf("Cycling through ");
display_set_coded_by(n);
printf("\n yields ");
display_set_coded_by(cycle(n));
puts(".");
return EXIT_SUCCESS;
}
void display_set_coded_by(int n) {
printf("{");
bool digits_found = false;
for (int i = 0; i < 10; ++i)
if (n & 1 << i) {
printf("%d, ", i);
digits_found = true;
}
if (digits_found)
printf("\b\b");
putchar('}');
}
int cycle(int n) {
/* ... REPLACE THIS COMMENT WITH YOUR CODE ..