the following main program:
#include <stdio.h>
void set_flag(int* flag_holder, int flag_position);
int check_flag(int flag_holder, int flag_position);
int main(int argc, char* argv[])
{
int flag_holder = 0;
int i;
set_flag(&flag_holder, 3);
set_flag(&flag_holder, 16);
set_flag(&flag_holder, 31);
for(i=31; i>=0; i--)
{
printf("%d", check_flag(flag_holder, i));
if(i%4 == 0)
{
printf(" ");
}
}
printf("\n");
return 0;
}
Write the code for the definition of set_flag and check_flag so that the output of your program looks like the following: You can think of the set_flag function as taking an integer and making sure that the nth bit is a 1. The check_flag function simply returns an integer that is zero when the nth bit is zero and 1 when it is 1. You may find the shifting
the output should be
1000 0000 0000 0001 0000 0000 000 1000
I dont understand the bold part of the question.
can someone explain the problem to me. So am supposed to check the nth bit of the integer. however the initial integer is 0. means that no nth bit has a value of 1. so What am i supposed to do here?