This is a C Program which calculates the normal of a given matrix.
Generally normal of a matrix is calculated as the root of sum of squares of all the elements in a matrix.
PROGRAM :
OUTPUT :
Generally normal of a matrix is calculated as the root of sum of squares of all the elements in a matrix.
PROGRAM :
#include <stdio.h> #include <stdlib.h> #include<math.h> int main() { int sum=0,rows,columns,i,j; float normal; printf("Enter order of matrix : \t"); scanf("%d%d",&rows,&columns); int matrix[rows][columns]; printf("Enter elements of the matrix \n"); for(i=0;i<rows;i++) { for(j=0;j<columns;j++) { printf("Enter element m%d%d: \t",i+1,j+1); scanf("%d",&matrix[i][j]); } } printf("\n\nMATRIX is :\n"); for(i=0;i<rows;i++) { for(j=0;j<columns;j++) printf("%d\t",matrix[i][j]); printf("\n"); } printf("\n\nIts NORMAL is:\n"); for(j=0;j<columns;j++) { for(i=0;i<rows;i++) sum = sum +pow( matrix[i][j] , 2 ); } normal = sqrt(sum); printf("%f\n",normal); return 0; }
OUTPUT :
C - Normal of a matrix |
No comments:
Post a Comment