rabbinur

3x3 array, store in it, min, max, averarage

Aug 23rd, 2012
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. #include<iostream.h>
  2. #include<conio.h>
  3. #define m 3
  4. #define n 3
  5.  void main()
  6.  {
  7.    int i, j, sum=0;
  8.    int x[m][n]={{5,6,7},
  9.         {8,9,10},
  10.         {11,12,13},
  11.         };
  12.    float average;
  13.    clrscr();
  14.    for(i=0; i<m; i++)
  15.    for(j=0; j<n; j++)
  16.     {
  17.      cout<<"x["<<i<<"]["<<j<<"]="<<x[i][j]<<endl;
  18.      sum=sum+x[i][j];
  19.     }
  20.      cout<<"sum of the numbers="<<sum<<endl;
  21.      average=sum/(float)(m*n);
  22.      cout<<"average="<<sum<<"/"<<m*n<<endl;
  23.      cout<<"average of the sum="<<average<<endl;
  24.      int min, max;
  25.      int a[9]={5,6,7,8,9,10,11,12,13};
  26.  
  27.      for(i=0; i<9; i++)
  28.      min=max=a[0];
  29.      for(i=0; i<9; i++)
  30.  
  31.       {
  32.     if(a[i]>max)
  33.     max=a[i];
  34.       }
  35.        {
  36.     if(a[i]<min)
  37.     min=a[i];
  38.        }
  39.     cout<<" minimum number of the given array="<<min<<endl;
  40.     cout<<" maximum number of the given array="<<max<<endl;
  41.  
  42.     getch();
  43.  }
Advertisement
Add Comment
Please, Sign In to add comment