search and sort program for class

I need urgent help with my code my program is due wednesday evening. program requirements as follows:

Write a C++ program, which will read a set of integer values from an external formatted data
file and store them in a 1-d array. There are no more than 40 integers in the file. Use the C++ idiom
while(count < SIZE && infile >> arr[count]) to read the information from the external data file. Your
LoadArr() function should probably have three parameters, 1. the array, 2. the size of the array, 3. a
reference variable which will keep track of the number of integers you actually read from the file. Do not
count the integers in the data file and then use a for() loop.
Once you have loaded the integers into your array you will:
1. Search the array for the smallest value. Print the value as well as its location.
2. Search the array for the largest value. Print the value as well as its location.
3. Sort the array in ascending order.
4. Search the array for the following key values: 88, -808, -999, 807, 876
If found, print out the location of the first occurrence of the key value
otherwise print out a message that the key is not found. The searches in this section
should be done using a modified linear search function.
5. Search the array for the following key values: 88, -808, -999, 807, 876
If found, print out the location of the first occurrence of the key value
otherwise print out a message that the key is not found. The searches in this section
should be done using a binary search function.
Your program should contain several functions. For example, LoadArr(), MaxLinearSearch(),
MinLinearSearch(), SortArray(), Swap(), ModifiedLinearSearch(), BinarySearch(). Pass the arrays along
with any additional infomation the function requires to do it's job. No global variables please!! Use an
external output file for all of the output.
Create an external data file with the following integers:
1 12 88 -999 87 876 -88 877 14 22 31 109
222 141 214 -44 -45 -45 -55 99 89 777 -466 38
278 103 21 55


this is my source code so far any help would be appreciated:


#include <iostream>
#include <fstream>
#include <cstdlib>
#include <iomanip>
#include <stdlib.h>
using namespace std;

int loadArr (int arr2[], int);
void smallPrint (int arr2[], int);
void largePrint (int arr2[], int);
void print (int location, int value);
void ascendingPrint (int arr2[], int);
void sortArray (int arr2[], int);
void showArray (int arr2[], int);
void searchList (int arr2[], int, int);
void binarySearch (int arr2[], int);
ofstream outfile ("c:\\butemp\\8fileout.txt");
int main()
{
const int size=40;
int arr2[size];
int count;
const int numKeys = 5;
int key[numKeys] = (88, -808, -999, 807, 876);
int index;
//for( int x = 0; x<numKeys;x++)
//index = (arr2, count, key[x]);


count = loadArr (arr2, size);

smallPrint (arr2, count);

largePrint (arr2, count);

ascendingPrint (arr2, count);

searchList (arr2, count, size);

binarySearch (arr2, count);

system ("pause");
return 0;
}

int loadArr (int arr2[], int size)
{ifstream infile ("c:\\butemp\\8.txt");

if ( ! infile )
{ cerr << "Input file could not be opened"<< endl;}


int count = 0;
while (count < size && infile >> arr2 [count])
count ++;

return count;

{




if ( ! outfile)
{ cerr <<"Output file could not be opened" << endl;}

outfile<<setw(10)<<"\t\t index"<<" "<<"\t\tContents"<<endl;
{const int size=28;
int arr2[size];

int x=0;
while (infile>>arr2[x])
while (x < size && infile >>arr2[x])
{
//cout << setw(20)<<x<<" "<<setw(15)<<arr2[x]<<endl;
x++;
}
{
return x;
}

}
{


void smallPrint (int arr2[], count)

}
you need to calm down. The easiest (and least efficient but good enough for a small sized list) is to just use bubblesort. (literally less than 10 lines of code).

You need to look up information. Google's your best friend. Dont' be lazy. If you are not willing to do a little R & D, don't expect freebies. That's what I learnt. If you invest the time and more realistically, started your assignment weeks before rather than procrastinate, you wouldn't be rushing like this.
Learning by doing, try it, if you fail, try it again, if fail, try it again -> See here -> http://www.youtube.com/watch?v=H8ZuKF3dxCY
Topic archived. No new replies allowed.