Last active
August 29, 2015 14:02
-
-
Save abouolia/aea1f0b93e5056e08422 to your computer and use it in GitHub Desktop.
Detrimental of center trig and sub trig of any matrix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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