/* Program to find
the norm of the given matrix */
/* The norm of the
matrix is defined as the square root of the sum of the squares of the elements
of a matrix */
#include<stdio.h>
#include<conio.h>
#include<math.h>
void
main()
{
int row,col,i,j,mat[100][100];
float s=0.0;
clrscr();
printf("Enter the number of
rows:");
scanf("%d",&row);
printf("Enter the number of
columns:");
scanf("%d",&col);
printf("\nEnter the elements:\n");
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
scanf("%d",&mat[i][j]);
}
}
printf("\n\nGIVEN MATRIX:\n");
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
printf("\t%d",mat[i][j]);
}
printf("\n");
}
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
s+=mat[i][j]*mat[i][j];
}
}
printf("\nNorm of the given matrix =
%f",sqrt(s));
getch();
}
OUTPUT
Enter
the number of rows:3
Enter
the number of columns:3
Enter
the elements:
2
4
6
8
1
3
5
7
9
GIVEN
MATRIX:
2
4 6
8
1 3
5
7 9
Norm
of the given matrix = 16.881943
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.