Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //W.P to input data into the array A[3][3] and find the average of the positive values in the second column and first row together
- #include<iostream>
- using namespace std;
- int main()
- {
- int a[3][3],i,j;
- for(i=0;i<3;i++)
- {
- for(j=0;j<3;j++)
- {
- cout<<"["<<i<<"]["<<j<<"]";
- cin>>a[i][j];
- }
- }
- for(i=0;i<3;i++)
- {
- for(j=0;j<3;j++)
- {
- cout<<a[i][j]<<"\t";
- }
- cout<<endl<<endl;
- }
- int k=0,sum=0;
- for(j=0;j<3;j++)
- {
- if(a[j][1]&&a[0][j]>0)
- {
- sum+=a[0][j]+a[j][1];
- k++;
- }
- }
- cout<<"sum = "<<sum;
- if(k==0)
- {
- cout<<"\nNot Found Positive Number\n";
- }
- else if(k!=0){
- float av=sum/k;
- cout<<"Av = "<<av;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment