Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q2.1) The following code implements the selection sort algorithm to sort an array of integers numbers of size n in ascending order. Edit the code

Q2.1) The following code implements the selection sort algorithm to sort an array of integers numbers of size n in ascending order. Edit the code to sort and print an array of float numbers of size n and to implement an additional function called swap to swap the items

void PrintArray(int size, int array []){

for(int i=0; iarray[j]){

temp = array[i];

array[i] = array[j];

array[j] = temp;

}

}

}

}

int main() {

int data [] = {2, 7, 8, -8, 1, 9, 3, 5};

SelectionSort(sizeof(data)/sizeof(int), data);

PrintArray(sizeof(data)/sizeof(int), data);

return 0;

}

Q2.2) change the PrintArray Function to print the memory address of each element in the array in addition to the element index within the array and the element value. What do you notice about the memory addresses of the array elements?

Q2.3) Write a C function named ArrayInfo( ) of type void that takes an array of n integers and calculate the sum of the elements in the array, the average, find the minimum value, the maximum value and made this information available to the main function. Hint use pointers and call by references

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database Design With Microcomputer Applications

Authors: Glenn A. Jackson

1st Edition

0137718411, 978-0137718412

More Books

Students also viewed these Databases questions

Question

Proficiency with Microsoft Word, Excel, PowerPoint

Answered: 1 week ago