I am having trouble figuring out how to write the following code and having the the two void functions? I am supposed to pass the values of the integer array to the functions using the call by reference method.
here is the code i have so far.

include <iostream>
#include <iomanip>
using namespace std;
void displayAll(int a[])
{
	int i=0,n=0;
	for (i=0;i<60;i++) cout << "=";
	cout << endl;
	for (n=0;n<4;n++)  cout << setw(12) <<right << a[n];
	cout << endl;
	for (i=0;i<60;i++) cout << "=";
    cout << endl;
	for (n=4;n<8;n++)  cout << setw(12) <<right << a[n];
	cout << endl;
	for (i=0;i<60;i++) cout << "=";
    cout << endl;
	for (n=8;n<12;n++)  cout << setw(12) <<right << a[n];
	cout <<endl;
	for (i=0;i<60;i++) cout << "=";
    cout << endl;

}
void sorting(int b[])
{
			int temp=0;
			for (int i=0; i<11; i++)
			for (int j=i+1; j<12; j++)
				if (b[i] < b[j]) {
					temp=b[i]; b[i]=b[j]; b[j]=temp;
			};
}
int main()
{
    int num[12]={90,77,23,10,80,20,70,30,60,40,50,15};
	cout << " The values in the Array before sorting are: "<< endl;
	displayAll(num);
	sorting(num);
	cout << " The values in the Array after sorting are: "<< endl;
	displayAll(num);
	return 0;
}

Code tags please. And try not mix spaces and tabs. it doesn't look good when posting since a tab here is 8 spaces.

[code=cplusplus] // paste code here

[/code]

#include <iostream>
#include <iomanip>
using namespace std;
void displayAll(int a[])
{
	int i=0,n=0;
	for (i=0;i<60;i++) cout << "=";
	cout << endl;
	for (n=0;n<4;n++)  cout << setw(12) <<right << a[n];
	cout << endl;
	for (i=0;i<60;i++) cout << "=";
    cout << endl;
	for (n=4;n<8;n++)  cout << setw(12) <<right << a[n];
	cout << endl;
	for (i=0;i<60;i++) cout << "=";
    cout << endl;
	for (n=8;n<12;n++)  cout << setw(12) <<right << a[n];
	cout <<endl;
	for (i=0;i<60;i++) cout << "=";
    cout << endl;

}
void sorting(int b[])
{
			int temp=0;
			for (int i=0; i<11; i++)
			for (int j=i+1; j<12; j++)
				if (b[i] < b[j]) {
					temp=b[i]; b[i]=b[j]; b[j]=temp;
			};
}
int main()
{
    int num[12]={90,77,23,10,80,20,70,30,60,40,50,15};
	cout << " The values in the Array before sorting are: "<< endl;
	displayAll(num);
	sorting(num);
	cout << " The values in the Array after sorting are: "<< endl;
	displayAll(num);
	return 0;
}

What sorting method are you using?

Code tags please. And try not mix spaces and tabs. it doesn't look good when posting since a tab here is 8 spaces.

[code=cplusplus] // paste code here

[/code]

#include <iostream>
#include <iomanip>
using namespace std;
void displayAll(int a[])
{
	int i=0,n=0;
	for (i=0;i<60;i++) cout << "=";
	cout << endl;
	for (n=0;n<4;n++)  cout << setw(12) <<right << a[n];
	cout << endl;
	for (i=0;i<60;i++) cout << "=";
    cout << endl;
	for (n=4;n<8;n++)  cout << setw(12) <<right << a[n];
	cout << endl;
	for (i=0;i<60;i++) cout << "=";
    cout << endl;
	for (n=8;n<12;n++)  cout << setw(12) <<right << a[n];
	cout <<endl;
	for (i=0;i<60;i++) cout << "=";
    cout << endl;

}
void sorting(int b[])
{
			int temp=0;
			for (int i=0; i<11; i++)
			for (int j=i+1; j<12; j++)
				if (b[i] < b[j]) {
					temp=b[i]; b[i]=b[j]; b[j]=temp;
			};
}
int main()
{
    int num[12]={90,77,23,10,80,20,70,30,60,40,50,15};
	cout << " The values in the Array before sorting are: "<< endl;
	displayAll(num);
	sorting(num);
	cout << " The values in the Array after sorting are: "<< endl;
	displayAll(num);
	return 0;
}

What sorting method are you using?

I am just using the jump sort that we went over in class.

I am just using the jump sort that we went over in class.

Never heard of jump sort. However, the program seems to sort fine and arrays are passed by reference, so you're fine there as far as I can tell. What's the problem?

Never heard of jump sort. However, the program seems to sort fine and arrays are passed by reference, so you're fine there as far as I can tell. What's the problem?

so is there a difference between call by reference and pass by reference??
reading the directions for writing this code the Prof brought attention to the call by reference instruction.

This question has already been answered. Start a new discussion instead.