Question: I am trying to do a homework problem for c++ and when I put in the code t says error external errors. I am using

I am trying to do a homework problem for c++ and when I put in the code t says error external errors. I am using visual studio and I tried to add the header but I don't know what I should put in the header. If I take out the header and put int main I still get an external error. Please help. thia is my code //Header file #include "stdafx.h" #include using namespace std;

//Function prototypes void BubbleSort(int arr[], int); void SelectionSort(int arr[], int);

//Main function void main() { int array1[8] = { 3,5,7,1,9,4,3,7 }; int array2[8] = { 3,5,7,1,9,4,3,7 }; int i;// loop variable // Displaying contents of first array cout << "contents of first array;" << endl; for (i = 0; i < 8; i++) cout << "" << array1[i]; cout << endl; //function call to sort using bubble sort BubbleSort(array1, 8); //Displaying contents of second array cout << "Contents of second array:" << endl; for (i = 0; i < 8; i++) cout << "" << array2[i]; cout << endl; //Function call to sort using SelectionSort SelectionSort(array2, 8); system("pause"); }//end main

//function defenitions void BubbleSort(int array[], int size) { bool swap; int temp; cout << "Bubble sort" << endl; do { swap = false; for (int count = 0; count < (size - 1); count++) { if (array[count] > array[count + 1]) { temp = array[count]; array[count] = array[count + 1]; array[count + 1] = temp; swap = true; } } for (int i = 0; i < size; i++) cout << array[i] << ""; cout << endl; } while (swap); } void SelectionSort(int array[], int size) { int startScan, minIndex, minValue; cout << "Selection Sort:" << endl; for (startScan = 0; startScan < (size - 1); startScan++) { minIndex = startScan; minValue = array[startScan]; for (int index = startScan + 1; index < size; index++) { if (array[index] < minValue) { minValue = array[index]; minIndex = index; } } array[minIndex] = array[startScan]; array[startScan = minValue];

for (int i = 0; i < size; i++) cout << array[i] << ""; cout << endl; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!