Get the answers you need at Westonci.ca, where our expert community is dedicated to providing you with accurate information. Connect with a community of experts ready to help you find solutions to your questions quickly and accurately. Connect with a community of professionals ready to help you find accurate solutions to your questions quickly and efficiently.
Sagot :
Answer:
#include<stdio.h>
int main(){
unsigned char var;
int p,n;
printf("a: ");
scanf("%x",&var);
printf("p: ");
scanf("%d",&p);
printf("n: ");
scanf("%d",&n);
while(1){
char command;
scanf("%c",&command);
if(command=='S'){
var=var | (((1<<n)-1)<<(p-1));
} else if(command=='R'){
var=var & ~(((1<<n)-1)<<(p-1));
} else if(command=='F'){
var=var ^ (((1<<n)-1)<<(p-1));
} else if(command=='D'){
printf("a = %02x H : ",var);
int i;
for(i=7;i>=4;i--){
printf("%d",((1<<i)&(var))>>i);
printf(" ");
for(i=3;i>=0;i--){
printf("%d",((1<<i)&(var))>>i);
printf(" B\n");
}
}
} else if(command=='I'){
printf("a = ");
scanf("%x",&var);
}
}
}
Explanation:
The C source code gets user inputs from a keyboard as integer numbers, p and n, which is converted to binary (8 bits of one and zero value) as the memory for the input hexadecimal number and character values are also inputs from the keyboard, used as flags to determine the way the hexadecimal number is stored or displayed.
Thanks for stopping by. We strive to provide the best answers for all your questions. See you again soon. Your visit means a lot to us. Don't hesitate to return for more reliable answers to any questions you may have. Stay curious and keep coming back to Westonci.ca for answers to all your burning questions.