C++ Program to find sum of each row and each column of a Matrix | C++ Program | Class XI

Write a C++ Program to find sum of each row and each column of a Matrix

NOTE: E&OE, means errors and omissions are expected and accepted, in other words, if there is any error in the following article, the same has to be corrected by the user or the beneficiary accordingly.
This article contains works derived from other reputed works of huge publication houses and notes that were made by me in my school life.These articles are just to help people who need these articles desperately and urgently. Any queries, complaints, and corrections will be enthusiastically entertained.




Write a C++ Program to find sum of each row and each column of a Matrix

Sum of each row and each column of a Matrix in C++ Programming Language

Code Sample 1 (for Dev C++ & CodeBlocks)

 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
   #include<iostream>
   
   using namespace std;
   
   int main()
   {
      int a[10][10], i, j, c[10],r[10], col, row;
      cout<<"Enter the number of rows and columns of the matrix:- \n"; //Press the Return Button once.
      cin>>row>>col;
      cout<<"\nEnter the elements of the matrix:-\n";
      for ( i=0; i<row; i++)
          for ( j=0; j<col; j++)
              cin>>a[i][j];
              
      cout<<"\nGiven Matrix is as given below:- \n";
      for ( i=0; i<row; i++)
      {
         cout<<"\n";
         for ( j=0; j<col; j++)
             cout<<a[i][j]<<"\t";
      }
      
      for ( i=0; i<row; i++)
      { 
          r[i]=0;
          for ( j=0; j<col; j++)
              r[i]+=a[i][j];
   }
   
   for ( j=0; j<col; j++)
   {
      c[j]=0;
      for ( i=0; i<row; i++)
          c[j]+=a[i][j];
   }
   
   cout<<endl<<endl;
   for ( i=0; i<row; i++)
       cout<<"\nThe sum of row number "<<i+1<<" is "<<r[i];
   for ( j=0; j<col; j++)
       cout<<"\nThe sum of column number "<<j+1<<" is "<<c[j];
       
   return(0);
   }



Code Sample 2 (for Turbo C++)

 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
   #include<iostream.h>
   #include<conio.h>
   
   void main()
   {
      clrscr();
   int a[10][10], i, j, c[10],r[10], col, row;
      cout<<"Enter the number of rows and columns of the matrix:- \n"; //Press the Return Button once.
      cin>>row>>col;
      cout<<"\nEnter the elements of the matrix:-\n";
      for ( i=0; i<row; i++)
          for ( j=0; j<col; j++)
              cin>>a[i][j];
              
      cout<<"\nGiven Matrix is as given below:- \n";
      for ( i=0; i<row; i++)
      {
         cout<<"\n";
         for ( j=0; j<col; j++)
             cout<<a[i][j]<<"\t";
      }
      
      for ( i=0; i<row; i++)
      { 
          r[i]=0;
          for ( j=0; j<col; j++)
              r[i]+=a[i][j];
   }
   
   for ( j=0; j<col; j++)
   {
      c[j]=0;
      for ( i=0; i<row; i++)
          c[j]+=a[i][j];
   }
   
   cout<<endl<<endl;
   for ( i=0; i<row; i++)
       cout<<"\nThe sum of row number "<<i+1<<" is "<<r[i];
   for ( j=0; j<col; j++)
       cout<<"\nThe sum of column number "<<j+1<<" is "<<c[j];
       
   getch();
   }



Sample Output:


Topic covered here from class XI course is Programs on String manipulations and Programs on array manipulations (1D & 2D).
___________________________________________________________________

Know more about stuff related to this practical experiment (Important for Boards):-
  • Viva Questions Array Manipulations.
  • Difference between Dev C++ and Turbo C++.
  • Difference between Dev C++ and CodeBlocks.
  • C++ Program to find the Product of the Matrices | C++ Program | Class XI
  • C++ Program to find the Sum of the Series, 1 – x/2! + x^2/3! – x^3/4! + x^4/5! .... | C++ Program | Class XI
  • Qualitative analysis for the identification of the functional group in the organic sample Acetic Acid (Example 1).
  • How to find out the mass of salt required to achieve the required concentration of a solution


Reference:-


For latest syllabus, both theory and practical papers for class XII, check out the CBSE’s official site http://cbseacademic.in/ for more info.


For more awesome coding and programs related to this language log onto http://www.thecrazyprogrammer.com or https://www.w3schools.in/.


___________________________________________________________________

Related Questions-
Loop Based program code
Loops for while
Array manipulations
Header files
Dev c++
Turbo C++
CodeBlocks
CBSE class 12 computer science practicals
CBSE class XII computer science practicals
Benzoic Acid





Aptitude Amplifier ©2017. All Rights Reserved.

$hide=mobile

Name

Arrays,6,Blogger,2,C++,9,CBSE,19,Chemistry,9,Class 11,9,Class 12,9,CodeBlocks,9,Coding,13,Compulsory English,9,Computer Science,9,Craft,1,CreMat,4,Dev C++,9,EduMat,67,English,9,George Bernard Shaw,1,Graduation,50,Hardware,2,IGNOU,47,Internet,9,KB,3,Loops,7,Network,11,Notes,49,Organic,6,Others,1,Physical,3,Post Graduation,43,Practicals XI,9,Practicals XII,9,Programming,9,Qualitative Analysis,6,Quantitative Analysis,4,R.K. Narayan,3,Rabindranath Tagore,1,SAP,97,Sociology,41,Sociology Honors,43,Software,8,Special,3,Stephen Leacock,3,Strings,2,Structures,1,Turbo C++,9,Tweaks and Tricks,23,University of Calcutta,50,William Shakespeare,1,Windows,5,Windows 7,2,Windows 8,2,Yoga,3,
ltr
item
Aptitude Amplifier: C++ Program to find sum of each row and each column of a Matrix | C++ Program | Class XI
C++ Program to find sum of each row and each column of a Matrix | C++ Program | Class XI
Write a C++ Program to find sum of each row and each column of a Matrix
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinradAHCDTJ2TkDitPH9mTOUBUknXY5_EdO_ALBld_HonyMYowue6CI9epp0dmOR5dzOWm4lbSeNWXnzPSa5MFbLOVMLg68ZLPRGdFXk1Qvsyeqj31zIAoQMVO6YBFI9aPSRJtGcSotnfn/s640/Screenshot+%25285%2529.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinradAHCDTJ2TkDitPH9mTOUBUknXY5_EdO_ALBld_HonyMYowue6CI9epp0dmOR5dzOWm4lbSeNWXnzPSa5MFbLOVMLg68ZLPRGdFXk1Qvsyeqj31zIAoQMVO6YBFI9aPSRJtGcSotnfn/s72-c/Screenshot+%25285%2529.png
Aptitude Amplifier
https://aptitudeamplifier.blogspot.com/2017/12/program-to-find-sum-of-each-row-and-column-matrix.html
https://aptitudeamplifier.blogspot.com/
https://aptitudeamplifier.blogspot.com/
https://aptitudeamplifier.blogspot.com/2017/12/program-to-find-sum-of-each-row-and-column-matrix.html
true
1849318885804408050
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy