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

Assembly Language Programming ( use of raspberry pi). In this assignment, you wi

ID: 3692658 • Letter: A

Question

Assembly Language Programming ( use of raspberry pi).

In this assignment, you will iteratively populate a fixed-size integer array of 20 elements, array_a, with values provided by the _generate function described below. Once array_a has been populated by _generate, you will then store the sorted values in increasing order into array_b, a second fixed-size integer array of 20 elements. The _generate function is defined in C as:

void generate(int n)

{

for(int i = 0; i < 20; i += 2)

{

array_a [i] = n + i;

array_a [i + 1] = -(n + i + 1);

}

}

When executed, your program will immediately wait for the user to enter the value of n, which will be a positive integer. Once n is entered, you will call the _generate procedure to populate array_a, then the _sort_ascending procedure to store the sorted contents of array_a into array_b(the values in array_a will remain unsorted, but array_b will be sorted). Once both arrays have been populated, you will then print the results in the following format before exiting the program (do not loop back to the program main, just exit after the printing is completed).

array_a [0] = x, array_b = y   

array_a [1] = x, array_b = y

array_a [2] = x, array_b = y

array_a [19] = x, array_b = y

Your main function take a single input in the following format, then immediately perform the operations specified above.

               

Points will be assigned as follows:

1. Main function correctly retrieves 1 input parameters, prints result in proper format (20points)

2. array_a and _generate procedure correctly implemented (25 points)

3. array_b and _sort_ascending procedure correctly implemented (25 points)

4. Printed result values are correct (30 points)

Hint: You are free to implement the sorting algorithm of your choice for _sort_ascending, but selection sort is probably the easiest.

Explanation / Answer

#include <stdio.h>

void sort(int array_a[], int n);

void generate(int n);

void main()

{

            int n,array_a[20],array_b[20];

            printf("Enter the value of N ");

        scanf("%d", &n);

generate(n);

            for (int c = 0 ; c < 20 ; c++ )

            printf("Elements in the array_a are: %d", array_a[c]);

sort (array_a[], 20);

            printf("Sorted list in ascending order: ");

            for (int c = 0 ; c < n ; c++ )

            printf("%d ", array[c]);

          for ( int c = 0 ; c < 20 ; c++ )

            array_b[c] = array_a[c];

            printf("The copied sorted array is :");

            for (int i = 0; i < 20; i++)

        printf(" array_b[%d] = %d", i, array_b[i]);

return 0;

}

void generate(int n)

{

int array_a[20];

            for(int i = 0; i < 20; i += 2)

   {

            array_a [i] = n + i;

            array_a [i + 1] = -(n + i + 1);

   }

}

void sort (array_a[], 20)

{

            int k, l, swap;

for (k = 0 ; k < 19 ; k++)

{

    for (l = 0 ; l < 20 - c - 1; l++)

    {

      if (array_a[l] > array_a[l+1])

      {

        /* Swapping */

            swap         = array_a[l];

        array_a[l]   = array_a[l+1];

        array_a[l+1] = swap;

      }

    }

}

}

note-the above code can help to answer the given question.

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