| #include <stdio.h>
#include <iostream> 
using namespace std;
void sortprocess();
void displayresult();
double n[6]={22,4,6,33,29,18};
int i,j,tot,num,tmp;
void main() {
  system("cls");
  num = 6;
  tot = 0;
  sortprocess();
  displayresult();
  cout << "Total = " << tot << "\n";
  cout << "Average = " << tot/num << "\n";
  getchar();
}
void sortprocess() {
  for (i=0;i<num-1;i++) {
     for (j=num-1;j>i;j--) {
       if (n[j-1] > n[j]) {
         tmp = n[j];
        n[j] = n[j-1];
        n[j-1] = tmp;
       }
     }
  }
}
void displayresult() {
  cout << "Result after sorting : " << "\n";
  for (i=0;i<num;i++) {
    cout << i+1 << " : " << n[i] << "\n";
    tot = tot + n[i];
  }
}
 |  |