1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
#include <iostream.h>
#include <conio.h>
int calcAverage(int[][3],double);
int findHighest(int[][3],int);
int main(){
const int x = 3;
int nombor[x][3] = {{1,2,3},{6,7,8},{11,12,13}};
int average;
average = calcAverage(nombor,x);
findHighest(nombor,x);
cout << "The average of all the elements are : " << average << endl ;
getch();
}
int calcAverage(int a[][3],double x){
int sum = 0;
int av;
for(int i = 0; i < x ; a++){
for(int j = 0; j <=3 ; j++){
sum += a[i][j];
}
}
av = sum / (x * 3);
return av;
}
int findHighest(int a[][3],int x){
int highest = a[0][0];
for(int i = 0; i <= x ; a++){
highest = a[i][0];
for(int j = 0; j <=3 ; j++){
if (a[i][j] > highest){
highest = a[i][j];
}
cout << "Highest number in row " << i+1 << " is " << a[i][j] << endl ;
}
}
return 0;
}
|