
Call 1800-123-2003
"Smartindia is the best online tool for school students." Ms Deepa Chandran, Principal Anchal
"Smartindia is one of the best supplementary education tool for school students." Ms Pooja, Principal
write a c++ program to find the norm of a matrix? |
#include<stdio.h> #include<conio.h> #include<math.h> void main() { int a[10][10],sum=0,i,j,m,n,trace=0; float norm; printf("enter order"); scanf("%d %d",&m,&n); printf("enter elements "); for(i=0;i<m;i++) {for(j=0;j<m;j++) scanf("%d",&a[i][j]); } for(i=0;i<m;i++) { for(j=0;j<m;j++) { sum=sum+(a[i][j]*a[i][j]); if(i==j) trace=trace+a[i][j]; } } norm=sqrt(sum); printf("norm=%f\n trace=%d",norm,trace); } |