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;
}