Please enter in a number between 0 and 4095: 1242 Please select one of the follo
ID: 665257 • Letter: P
Question
Please enter in a number between 0 and 4095: 1242 Please select one of the following functions: e : Extract bits of a field s : Set bits of a field The user will then type in a character followed by the ENTER key. Your program will respond accordingly. Assume the user enters 's'. Please enter in the lab of the field: Assume the user enters '3'. Please enter in the length of the field: Assume the user enters '10'. The initial value in binary is: The result in binary is: The parity of the result is: Odd Would you like to quit (y/n)? y Goodbye.Explanation / Answer
working c code
#include<stdio.h>
#include<math.h>
int main(){
long int decimalNumber,remainder,quotient;
int binaryNumber[100],i=1,j;
printf("Enter any decimal number: ");
scanf("%ld",&decimalNumber);
int lsb,length;
printf("Please enter in the lsb of the fiels ");
scanf("%d",&lsb);
printf("Please enter the length of the field ");
scanf("%d",&length);
int l;
int mask;
mask=0;
mask=pow(2,length);
mask =mask-1;
mask=mask<<lsb;
quotient = (decimalNumber|mask);
while(quotient!=0){
binaryNumber[i++]= quotient % 2;
quotient = quotient / 2;
}
for(j = i -1 ;j> 0;j--)
printf("%d",binaryNumber[j]);
return 0;
}