Write a C Program to Calculate the Trace and Normal of a Matrix

Trace and Normal of Matrix
Statement of C Program: This Program accepts a square matrix and prints the Trace and Normal of the Matrix.

Trace of Matrix



Trace: Trace of a Matrix can be defined as the sum of the main diagonal elements.






Normal of Matrix 



Normal: Normal can be defined as the square root of the sum of squares of all the elements of a Matrix.





#include<stdio.h>
#include<conio.h>
void main()
{
int i , j , n ;                                       /* 'i' used for Rows and 'j' used for Columns */
int Row , Column;
int Matrix[9][9];
float trace , sum , normal;

clrscr();
trace = 0;
sum = 0;

printf(" Enter the order of Matrix\n");
scanf("%d * %d" , &Row , &Column);

printf(" Enter the elements of Matrix\n");
for(i=0 ; i<Row ; i++)
{
for(j=0 ; j<Column ; j++)
{
scanf("%d" , &Matrix[i][j] );
}
}

                                                  /* Trace and Normal */

for(i=0 ; i<Row ; i++)
{
for(j=0 ; j<Column ; j++)
{
if(i==j)
{
trace + = Matrix[i][j];                   /* It can also be Written as  trace=trace+Matrix[i][j]  */
}
sum + = pow( Matrix[i][j] , 2 );       
}
}
normal = sqrt(sum);

printf(" Trace = %f\n" , trace);
printf(" Normal = %f\n" , normal);
getch();
}                                                               /* End of main() */
 

0 Response to "Write a C Program to Calculate the Trace and Normal of a Matrix"

Post a Comment

Popular Posts

Label

1 Sidebar 2 Columns 3 Columns Footer 3rdball 4 Columns Footer Alex Alvaro Antsasia Arlinadesign Averie Barry BASIC CONCEPTS Basil Bayna Fast BeautyPress BeautyTemplates Beckel Best Best - Clean Beyonce Pro BioMag BlackMag Blanter Nova Blogger Card Bloggertheme9 Blogish Bpress Brakt C LANGUAGE C PROGRAMS C++ LANGUAGE C++ PROGRAMS Carella Cellar Charlotte Chooko Lite Clara Clean Combo One Cooperate Crusade Darry Dorman Dreamway Dunia Blanter eCars EduAcademy EducationPress Elise Elvan Eva Everyday FabNews Fashion Fashion Blogger Template Fashion Gossip FastCars Fedo FlashNews Fredy Portfolio Gaming Globus GoodTime Goomsite HTML LANGUAGE iGaming Indicate Innove Insomnia InspiredNews iSoft Jasmine Kalem Landscaping Lashira Lavelle Lily Fashion Limax Linea Lionex Luminescence Lite Lumix Luxury Magazine MagazinePro MAJOR DIFFERENCES MarketingBlog Martin MaxiMag Medica Mega Melissa Mercury MeshMag Minimag Minimalist MiniNews MovieKhor msdesignbd MusicLand Neko NetZine New Spread News16 Newsflash NewsForce NewsIdea Newspaper News NewsPro Nubie Fast Odd Themes Optima PaperMag PaperMag blog Parhlo Perfection Personal Personal Blog Photosout PixelZ Power Blog Premium Themes ProfileMag Purez Rano ReadNews Real estate Remito Grid Responsive Revo Robusta Rotario Saara SeoBoost Settle Shouters Simple Catch SimpleClean Sketchly SNews SolidMag Someo Sophie Sora Sora Bank Sora Home Sora News Responsive Sora One Sora Ribbon Spido Sticko Stucco Sure Mag Swift Tech Tech Pro Techia Techmax TechSpot TemplateClue Templateism Templatesilk Templatesyard Templatezy The Freelancer TheBlogger TheFocus Themeforest Themexpose TIPS AND TRICKS Topside TravelMag Trendy Trendy Travel Tumblr Under Construction Uong Jowo Veethemes Vertox VideoPlay Vigo Waverly way2themes WebBiz Wedding X-Mag Zealer ZetaMag