Skip to content

Instantly share code, notes, and snippets.

@Nazmul56
Created July 4, 2018 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nazmul56/5dfe0b76248559651ad4bf09cff76216 to your computer and use it in GitHub Desktop.
Save Nazmul56/5dfe0b76248559651ad4bf09cff76216 to your computer and use it in GitHub Desktop.
Sum Of Row and Column
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
int R; int C;
int inputArray[100][100] = {0};;
int tc;
scanf("%d %d ", &R, &C);
for(int row =0; row < R; row++){
for(int cloumn = 0; cloumn < C; cloumn ++){
int input;
scanf(" %d", &input);
inputArray[row][cloumn] = input;
}
}
for(int row =0; row <=R; row++){
int rowSum =0;
int cloumnSum =0;
for(int cloumn = 0; cloumn <= C; cloumn ++){
int value = inputArray[row][cloumn];
rowSum = rowSum + value;
if(row == R){
} else {
inputArray[R][cloumn] = inputArray[R][cloumn]+ inputArray[row][cloumn];
}
if(cloumn == C){
} else{
inputArray[row][C] = rowSum;
}
printf("%d ", inputArray[row][cloumn]);
}
printf("\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment