/*
* 1000+ C programs + tutorials
*
*
* 87_c_program_do_display_2x2_matrix.c
*
*
*
* Created on: Oct 25, 2014
* Author: Code2care.org
*/
#include
//#include
void main() {
int arr[2][2];
int i,j;
//clrscr();
printf("C 2x2 Matrix : ");
//Read the elements of the 2x2 matrix
for(i=0;i<=1;i++) {
for(j=0;j<=1;j++) {
printf("\nEnter element at location %d,%d : ",i+1,j+1);
scanf("%d",&arr[i][j]);
}
}
printf("\n\n Entered 2x2 matrix : \n\n");
//Display the elements of 2x2 matrix
for(i=0;i<=1;i++) {
for(j=0;j<=1;j++) {
printf("%d ",arr[i][j]);
}
printf("\n");
}
//getch();
}
-
Output :
C 2x2 Matrix :
Enter element at location 1,1 :
Enter element at location 1,2 :
Enter element at location 2,1 :
Enter element at location 2,2 :
Entered 2x2 matrix :
1 2
3 4
The best way to learn C programming is to practice more and more of programs .
Code2care C Programming tutorials provide 1000+ programs in C that you can study and become an expert in the language. Programs are divided into categories depending upon type and complexity.
BSc. IT, BSc. Computer Science, BSc. IT, MSc. IT, MSc. Computer Science, MCA, BTech IT & BTech Engineers may find these programs very useful.