A blog to help students to learn programming in various languages including C, C++, Java, Python and many more.

Subscribe For Free Latest Updates!

We'll not spam mate! We promise.

Showing posts with label 2d array. Show all posts
Showing posts with label 2d array. Show all posts

Saturday, 16 January 2016


Program ScreenShot

#include<iostream>
using namespace std;
int main()
{
int a[100][100];
int r,c;
cout<<"Enter no. of rows & columns: ";
cin>>r>>c;;
cout<<"Enter "<<r*c<<" values : ";
for(int i=0;i<r;i++) {
for(int j=0;j<c;j++) {
cin>>a[i][j];
}
}
for(int i=0;i<r;i++) {
for(int j=0;j<c;j++) {
a[i][c]+=a[i][j];
}

}
for(int i=0;i<r;i++) {
for(int j=0;j<c+1;j++) {
a[r][j]+=a[i][j];
}

}
cout<<"SUM : "<<"\n";
for(int i=0;i<r+1;i++) {
for(int j=0;j<c+1;j++) {
cout<<a[i][j]<<" ";
}
cout<<"\n";
}
}

Read More >>


Copyright © 2016 - ProgrmIt - All Rights Reserved
(Articles Cannot Be Reproduced Without Author Permission.)
Design By : | Powered By: Blogger