Skip to content

Instantly share code, notes, and snippets.

@abouolia
Last active August 29, 2015 14:02
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 abouolia/aea1f0b93e5056e08422 to your computer and use it in GitHub Desktop.
Save abouolia/aea1f0b93e5056e08422 to your computer and use it in GitHub Desktop.
Detrimental of center trig and sub trig of any matrix
#include<stdio.h>
//Created By Ahmed Bouhuolia
main(){
int i, j, n, m, matrix[256][256], sum;
printf("Enter the number of rows and columns of the matrix ");
scanf("%d %d", &n, &m);
printf("Enter the elements of the matrix %d*%d ", n, m);
for( i = 0; i < n; i++ ){
for( j = 0; j < m; j++){
scanf("%d", &matrix[i][j]);
}
}
for( i = 0; i < n; i++ ){
for( j = 0; j < m; j++ ) {
if( i + j == m - 1 ){
sum = sum + matrix[i][j];
}
if( i == j){
sum = sum + matrix[i][j];
}
}
}
printf("%d", sum);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment