arrays and void functions

Oct 14, 2009 at 5:39am
Hi guys, I need help with arrays and functions. I have to do the following:Write a C++ program that has a main function and one void function.

The void function is to be named sortof and will be called by the main function. The function sortof has two arguments, each of which are one-dimensional arrays of length four. The main program prompts the user for four numbers. These four numbers are stored in one of the two arrays. The function is then called and it sorts the numbers into their proper order, storing them in order (lowest to highest) in the second array. The main program then prints out the unsorted and sorted array to the screen.

You don't have to use a fancy sorting routine, just determine the max, the min and then do the same for the two numbers left behind.
------------------------------------------------
what I've done:

using namespace std;
#include<iostream>
#include<cmath>
#include<iomanip>
void sortof(int[], int[]);
int main()
{ int st, sr,n;
int storearray[4], sortarray[4];
int a, b , c, d;
cout<<"Enter four numbers: ";
sortof(storearray, sortarray);
for(n=0; n<4; n++)
{
cin>>st;
storearray[n]=st;
}

cout<<fixed<<setw(6)<<"\nUnsorted numbers"<<setw(25)<<"Sorted numbers"<<endl;

for(n=0; n<4; n++)
{
cout<<setw(6)<<storearray[n];
};
if (a==sr)cout<<"The greater number"<<endl;

system ("pause");
return 0;
}

void sortof(int st[], int sr[])
{ int n;
int store, store_ind;
int sort, sort_ind;
store=st[0];
store_ind=0;
for(n=0; n<4; n++)
{ if (store<st[n])
sr[n]=st[n];
};
}
Oct 14, 2009 at 5:40am
What is the problem?
Oct 14, 2009 at 5:47am
Oh, wow. This is a new one. He posed the same thread twice, but the second time, he included less information.

http://www.cplusplus.com/forum/general/15324/
Topic archived. No new replies allowed.