Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Visual C# And Databases

Authors: Philip Conrod, Lou Tylee

16th Edition

1951077083, 978-1951077082

More Books

Students also viewed these Databases questions

Question

What is the difference between Needs and GAP Analyses?

Answered: 1 week ago

Question

What are ERP suites? Are HCMSs part of ERPs?

Answered: 1 week ago