Question: Write a C++ program to do a swap sort of smallest integer using the following int main with after swap (swap (list, 1,9) and after
Write a C++ program to do a swap sort of smallest integer using the following "int main" with "after swap" (swap (list, 1,9) and "after sort"; then screen print:
int main(){ int list[ARRAY_SIZE]={56,1,25,-254,78,35,0,54,-8,-999}; printArray(list, ARRAY_SIZE); cout<< "The smallest element (index) in the list is "< cout<< "After sort "< cin.get(); void swap(int list[], int i, int j){ int temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } void sort(int list[], int listSize){ //your code goes here // you have to call (use) functions swap and smallestIndex } int smallestIndex(int list[], int listSize){ int smallestNum=list[0]; int indexOfSmallestNum=0; for(int i=1;i return indexOfSmallestNum; } void printArray(int list[], int listSize){ for(int i=0;i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
