Answer to Question #211784 in C++ for Need it ASAP

Question #211784

Topic: Basics of C++ Programming Language "ARRAY IN C++"


Codes discussed will be posted here. Write your conclusion on the File stream discussion. 


Filename: Ch8_SelectionSort.cpp


Code:

-->>https://drive.google.com/file/d/1gPf5uykpETwV7zRMxe2goq14z1PoTCEg/view?usp=sharing


*Note need proper codes and conclusion on how it's done and about the results. And please give the proper solution and explanation.


Note: Place your conclusion on why did it turn out like that and give your reasons why the results turned like that, one paragraph will do for the explanation and conclusion.


Note: Please place the proper conclusion and explanations and results of the codes which were given.


1
Expert's answer
2021-07-02T04:10:32-0400
#include <iostream>
	using namespace std;
	

	void selectionSort(int arr[], int arr_size);
	void printArray(int arr[], int arr_size);
	

	int main(int argc, const char * argv[]) {
	    // insert code here...
	    int arr_size= 5;
	    int arr[5] = {3,1,2,5,4};
	    
	    selectionSort(arr, arr_size);
	    printArray(arr, arr_size);
	    return 0;
	}
	

	void selectionSort(int arr[], int arr_size){
	    for (int i=0; i< arr_size; ++i) {
	        for (int j =i+1; j< arr_size; ++j) {
	            if (arr[i]>arr[j]) {
	                int temp = arr[i];
	                arr[i]=arr[j];
	                arr[j]=temp;
	            }
	        }
	    }
	}
	

	void printArray(int arr[], int arr_size){
	    //read every element of the array
	    for (int i = 0; i<arr_size; ++i) {
	        cout<< " " <<arr[i];
	    }
	    //print out that element
	}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS