c++,just to do the flowcharts

profilemanksa
q.6_in_lab9.docx

Q.6 Lab#9

// This program uses selection sort algorithm to sort a string array in ascending order

#include Ciostream>

#include <string>

using namespace std;

//Function prototypes

void selectionSort(string [],int);

void showArray(string [], int);

//Main function

int main()

{

const int SIZE=20;

//Initializing array with given data

string names[SIZE]=

("Collins, Bill", "Smith, Bart", "Michalski, Joe", "Griffin, Jim", "Sanchez, Manny",

"Rubin, Sarah", "Taylor, Tyrone","Johnson, Jill","Allision, Jeff", "Moreno, Juan",

"Wolfe, Bill", "Whitman, Jean", "Moretti, Bella", "Wu, Hong","Patel, Renee",

"Harrison, Rose", "Smith, Cathy", "Conroy, Pat", "Kelly, Sean", "Holland, Beth");

//Display the values

cout<<"The unsorted values are\n";

showArray[names,SIZE];

//Sort the array

selectionSort[names,SIZE];

//Display the values again

cout<<"The sorted values are\n";

showArray[names,SIZE];

system["pausen];

return 0;

}//End of Main

// selectinSort

//This function performs an ascending-order selection sort on a string array.

void selectionSort[string names[],int size]

{

int startScan,minIndex;

string minvalue;

for[startScan=0;startScanC[size-1];startScan++]

{

minIndex=startScan;

minValue=names[startScan];

for(int index=startScan+landex<sizeandex++)

{

/*if current indexed value less than minValue*/

if(names[index].compare(minValue)<O)

{

minValue=names[index];

minIndex=index;

}

}//End of inner-loop

names[minIndex]=names[startScan];

names[startScan]=minValue;

}//End of main loop

}//End of function

//showArray

//This function displays the content of the array

void showArray(string names[],int size)

{

//Displaying data

for[int count=0;count<size;count++]

cout<<names[count]<<endl;

}//End of function

C:\Users\z\Pictures\5.JPG