Program to display the sum of each row elements

Tuesday, August 11, 2020

//Program to display the sum of each row elements

#include<iostream.h>

#include<conio.h>

#include <math.h>

void main()

{ clrscr();

 int P[10][10],m,n,i,j,sum1=0;

 cout<<"\n enter the no of rows for P:";

 cin>>m;

 cout<<"\n enter the no of columns for P:";

 cin>>n;

 for(i=0;i<m;i++)

 {

  for(j=0;j<n;j++)

  {

   cout<<"\n enter P["<<i<<"]["<<j<<"] elements:";

   cin>>P[i][j];

  }

 }

cout<<"\n the matrix P is:";

for (i=0;i<m; i++)

{cout<<"\n";

for(j=0; j<n; j++)

cout<<P[i][j]<<" ";

}

for(i=0;i<m; i++)

{sum1=0;

for(j=0; j<n; j++)

sum1+=P[i][j];

cout<<"\n Sum of row"<<i+1<<"="<<sum1;

}

getch();

}

You Might Also Like

0 Comments

Like us on Facebook

Flickr Images

Flickr Short Films