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

PROGRAM #2(a)\"* For more practice with conditional branches, write a program th

ID: 2293830 • Letter: P

Question

PROGRAM #2(a)"* For more practice with conditional branches, write a program that will sort an array of 10 unsigned 32-bit numbers into ascending order. Test the program with the following array of numbers. Array dod 30,55,129,18,5,20,200,4,220,100 Turn in printouts of your source program and the memory window from the debugger after running the program. In the memory window, show and highlight the sorted array in memory. PROGRAM #2(b)"* Modify Program #2(a) so that it will sort an array of 10 signed 32-bit numbers. (Hint -you should only need to change a couple of branch instructions.) Test the program with the following array: Array2 ded 30,-55,129,-18,-5,20000,-3200,4,220,-100

Explanation / Answer

#include <stdio.h>

void main ()

{

int number[10];

int x, y, z, n;

printf("Enter the value of N ");

scanf("%d", &n);

printf("Enter the numbers ");

for (x = 0; x < n; ++x)

scanf("%d", &number[x]);

/* sorting begins ... */

for (x = 0; x < n; ++x)

{

for (y = x + 1; y < n; ++y)

{

if (number[x] < number[y])

{

z = number[x];

number[x] = number[y];

number[y] = z;

}

}

}

printf("The numbers arranged in descending order are given below ");

for (x = 0; x < n; ++x)

{

printf("%d ", number[x]);

}

}

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