Given an array A (8,8). Find the sum and the number of positive elements, located below the main diagonal the smallest element of the array (minimum).
please help answer
#include <iostream>
using namespace std;
int main() {
int A[8][8];
int sumNumberPositiveElements=0;
for(int i=0;i<8;i++){
for(int j=0;j<8;j++){
cout<<"Enter number ["<<i<<"]"<<"["<<j<<"]: ";
cin>>A[i][j];
}
}
int smallestElementArray=A[0][0];
for(int i=0;i<8;i++){
for(int j=0;j<8;j++){
if(i>j){
sumNumberPositiveElements+=A[i][j];
}
if(smallestElementArray>A[i][j]){
smallestElementArray=A[i][j];
}
}
}
cout<<"\nSum of elements below the diagonal: "<<sumNumberPositiveElements<<"\n";
cout<<"The smallest element of the array: "<<smallestElementArray<<"\n";
system("pause");
return 0;
}
Comments
Leave a comment