Homework Help Question & Answers

JUST GIVE ME THE C CODE FOR THIS QUESTION. I GOT THE ASSEMBLY CODE.

In this assignment, you will create a C program that iteratively populates a fixed-size integer array of 3 elements, array α.Endian Conversion ar raya [ 2] \t=\ t«VALUE 2 >binary| t«VALUE 2 >decimal丶t«VALUE 22hex - - 一 For example, the following outp

JUST GIVE ME THE C CODE FOR THIS QUESTION. I GOT THE ASSEMBLY CODE.

In this assignment, you will create a C program that iteratively populates a fixed-size integer array of 3 elements, array α.withhexadecimal integer valuesprovided by scanf. The user will enter 3 positive hexadecimal integer values, one per line, and the program will store the 3 values in arYay _afOJ,arvay aflJ, and crr ay_af2J. Once the 3 integers are entered, your program will print the array ain 32 bit binary, decimal, and hexadecimal format. Then your program will call an assembly procedure that will either perfom a Bit Reverse Order Operation or a convert operation between 8-bit Endians (little and big) Your program onl y needs to do one. Your assembly procedure will edit the contents of array a to their new values. Once completed, your procedure will return control to your C program Your C program will then print the mo dified array a in both decimal and hexadecimal format After all output has been displayed, the program should exit (do not prompt for additional input) Input will be entered by the user in the following form: VALUE O>ENTER> VALUE 1>ENTER> VALUE 2 Once all of the input is entered, output will be printed in the following format (where is one of the integers provided by the user) array ar0] t-\tbinary\tdecimall t hex array a[2] \t-\tbinary\tdecimall t hex If performing the Bit Reverse Order, the following output will be displayed once the operation is complete BIT REVERSE ORDER a[1]\t=\t«VALUE 1>binary丶t«VALUE 1-dec imalt«VALUE 12hex array If performing the Endian Conversion, the following output will be displayed once the op eration is complete: Endian Conversion a[0]\t=\t«VALUE 0>b inar y\t«VALUE 0>dec imal\t«VALUE 0>hex array
Endian Conversion ar raya [ 2] \t=\ t«VALUE 2 >binary| t«VALUE 2 >decimal丶t«VALUE 22hex - - 一 For example, the following output is displayed when the user enters (FF, 308, 44325A32) for the array values (both Bit Reverse Order and Endian conversion are shown, but only oneneeds to be present in your solution) ar raya [O] \t=\t000000000000000000000000 11111111\t255\tFF array a[1]\t-\ t00000000000000000000001100001000t7761t308 ar ray a[2]\t=\t01000100 0 0 1 100 100101101000110010\t1144150578\t44325A32 BIT REVERSE ORDER ar ray a[0]\t=\ t 1 1111111000000000000000000000000丶t4278190080\tFF00 0000 array a[1]\t-\t00010000110000000000000000000000 t 17563 648 t10co000 ar ray a[2]\t=\t0 1001100010110100100110000100010\t12809 8 6 14 6\t4C5A4C22 Endian Conversion ar ray a[0]\t=\ t 1 1111111000000000000000000000000丶t4278190080\tFF00 0000 ar ray a[1]\t=\t00001000 000000110000000000000000\t134414336\t08030000 array_a[2] t-t001100100101101000110010010001001t844771908 t325A3244
0 0
ReportAnswer #1

#include <stdio.h>

int main(void)
{
   unsigned int array_a[3],a;
int d,c,k,i;
   //%x for hex input
   printf("Enter hexadecimal value without \"0x\": ");
   scanf("%x", &array_a[0]);
printf("Enter hexadecimal value without \"0x\": ");
   scanf("%x", &array_a[1]);
printf("Enter hexadecimal value without \"0x\": ");
   scanf("%x", &array_a[2]);
//hex
   printf("array_a[0] = 0x%x \narray_a[1] = 0x%x \narray_a[2] = 0x%x \n", array_a[0],array_a[1],array_a[2]);
//decimal
printf("array_a[0] = %d \narray_a[1] = %d \narray_a[2] = %d \n", array_a[0],array_a[1],array_a[2]);
  
for(i=0;i<3;i++){
//pick one element at a time to convert
a = array_a[i];
//convert decimal to binary
//c starts from 31 as we are doing 32 bit representation
for (c = 31; c >= 0; c--)
{
k = a >> c;
//k is and with 1 if it is 1 output will be 1 0 otherwise
if (k & 1)
printf("1");
else
printf("0");
}

printf("\n");
}

   return 0;
}

output

Enter hexadecimal value without Ox: aa Enter hexadecimal value without Ox: 41 Enter hexadecimal value without Ox: 74 ar

Add Homework Help Answer
Add Answer of:
JUST GIVE ME THE C CODE FOR THIS QUESTION. I GOT THE ASSEMBLY CODE.
Your Answer: Your Name: What's your source?
Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
More Homework Help Questions Additional questions in this topic.
Need Online Homework Help?
Ask a Question
Get FREE EXPERT Answers
WITHIN MINUTES
Related Questions