Advertisement
dirtydevil123

2d array

Jul 3rd, 2021
1,076
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     double marks[3][2];
  7.  
  8.     for(int i=0; i<3; i++)
  9.     {
  10.         for(int j=0; j<2; j++)
  11.         {
  12.             cin>>marks[i][j];
  13.         }
  14.     }
  15.  
  16.     for(int i=0; i<3; i++)
  17.     {
  18.         for(int j=0; j<2; j++)
  19.         {
  20.             cout<<marks[i][j]<< " ";
  21.         }
  22.         cout<<endl;
  23.     }
  24.  
  25.     for(int j=0; j<2; j++)
  26.     {
  27.         double sum = 0;
  28.         for(int i=0; i<3; i++)
  29.         {
  30.             sum= sum+ marks[i][j];
  31.         }
  32.         cout<<"avg marks of course "<<j << " is "<<(sum/3)<<endl;
  33.     }
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement