Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The following exercises may be completed in either 32-bit mode or 64-bit mode. 1

ID: 3681133 • Letter: T

Question

The following exercises may be completed in either 32-bit mode or 64-bit mode. 1. Converting from Big Kndian to Little Endian Write a program that uses the variables below and MOV instructions to copy the value from bigEndian to littleEndian. reversing the order of the bytes. The number's 32-bit value is understood to be 12345678 hexadecimal..data bigEndian BYTE 12h,34h,56b,78h littleEndian DWORD? 2. Exchanging Pairs of Array Values Write a program with a loop and indexed addressing that exchanges every pair of values in an array with an even number of elements. Therefore, item i will exchange with item i+I, and item t+2 will exchange with item i+3, and so on. 3. Summing the Gaps between Array Values Write a program with a loop and indexed addressing that calculates the sum of all the gaps between successive array elements. The array elements are doublewords, sequenced in nonde-creasing order. So, for example, the array {0, 2, 5, 9, 10} has gaps of 2. 3, 4, and 1, whose sum equals 10.

Explanation / Answer

Exchanging the pairs of array value

#include <stdio.h>
#define MAX 100
int main()
{
    int arr[MAX],n,i;
    int temp;
    
    printf("Enter total number of elements: ");
    scanf("%d",&n);
    
    //value of n must be even
    if(n%2 !=0)
    {
        printf("Total number of elements should be EVEN.");
        return 1;
    }
    //read array elements
    printf("Enter array elements: ");
    for(i=0;i < n;i++)
    {
        printf("Enter element %d:",i+1);
        scanf("%d",&arr[i]);
    }
    //swap adjacent elements
    for(i=0;i < n;i+=2)
    {
        temp    = arr[i];
        arr[i] = arr[i+1];
        arr[i+1]= temp;
    }
    
    printf(" Array elements after swapping adjacent elements: ");
    for(i=0;i < n;i++)
    {
        printf("%d ",arr[i]);
    }
    return;
}

------------------------------------------------------------------------------------------------------

Summing the Gaps between Array Values

#include <stdio.h>
#define MAX 100
int main()
{
    int arr[MAX],n,i;
    int temp;
   int sum=0;
    printf("Enter total number of elements: ");
    scanf("%d",&n);
    
   
    //read array elements
    printf("Enter array elements: ");
    for(i=0;i < n;i++)
    {
        printf("Enter element %d:",i+1);
        scanf("%d",&arr[i]);
    }
    
    for(i=0;i < n-1;i++)
    {
   sum+=(arr[i+1]-arr[i]);
    }
    printf("total difference between array elements %d",sum);
    return;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote