WAP of C language to Print the Matrix of Fixed or Desired Order

Matrix
Statement of C Program: This Program Reads and prints the elements of a Matrix:

#include<stdio.h>
#include<conio.h>
void main()
{
int matrix[9][9] ;                           /* Maximum Elements in the Matrix is 81 */
int matrix[3][3];                                      /* matrix of 9 elements */
int i, j;                                        /* 'i' used for rows and 'j' used for columns */
clrscr();

printf(" Enter the elements of Matrix\n");
for(i=0 ; i<3 ; i++)
{
for(j=0 ; j<3 ; j++)
{
scanf("%d" , &matrix[i][j] );
}
}                          /* Elements of Matrix Read (Input) with the help of scanf() Function */


printf(" Matrix is:\n");
for(i=0 ; i<3 ; i++)
{
for(j=0 ; j<3 ; j++)
{
printf("%d\t" , matrix[i][j] );                           /* '\t' used for Tab */
}                                                                    
printf("\n");                                          /* '\n' used for next line character */
}

getch();
}                                                                    /* End of main */


 Output:
 Enter the elements of Matrix
 9
 8
 7
 6
 5
 4
 3
 2
 1
 Matrix is:
 9   8   7
 6   5   4
 3   2   1


=> Note:  If you want to Print the Matrix of any Order then make few changes (Blue Colour) in the above Matrix. 

#include<stdio.h>
#include<conio.h>
void main()
{
int matrix[9][9];                                  /* Matrix of 81 Elements */
int i, j;
int Row , Column ;
clrscr();

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] );
}
}

printf(" Matrix is:\n");
for(i=0 ; i<Row ; i++)
{
for(j=0 ; j<Column ; j++)
{
printf("%d\t" , matrix[i][j] );
}
printf("\n");
}
getch();
}

 Output:
 Enter the order of Matrix
 3  3
 Enter the elements of Matrix
 9
 8
 7
 6
 5
 4
 3
 2
 1
 Matrix is:
 9   8   7
 6   5   4
 3   2   1

                                                                     That's All

0 Response to "WAP of C language to Print the Matrix of Fixed or Desired Order"

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