اكتب برنامج بلغة C لمصفوفة ثنائية الأبعاد بحجم 3x3 واطبع المصفوفة

  • برمجة
  • برمجة سي c

اكتب برنامج بلغة C لمصفوفة ثنائية الأبعاد بحجم 3x3 واطبع المصفوفة

الخرج المتوقع :

 

Read a 2D array of size 3x3 and print the matrix :
------------------------------------------------------
Input elements in the matrix :
element - [0],[0] : 1
element - [0],[1] : 2
element - [0],[2] : 3
element - [1],[0] : 4
element - [1],[1] : 5
element - [1],[2] : 6
element - [2],[0] : 7
element - [2],[1] : 8
element - [2],[2] : 9
                                                                                                              
The matrix is :
                                                                                                              
1       2       3
4       5       6
7       8       9

الأجوبة

/*Write a program in C for a 2D array of size 3x3 and print the matrix*/

#include <stdio.h>

void main()
{
  int arr1[3][3],i,j;
  
       printf("\n\nRead a 2D array of size 3x3 and print the matrix :\n");
       printf("------------------------------------------------------\n");  
  
 
    /* Stored values into the array*/
       printf("Input elements in the matrix :\n");
  for(i=0;i<3;i++)
  {
      for(j=0;j<3;j++)
      {
	      printf("element - [%d],[%d] : ",i,j);
	      scanf("%d",&arr1[i][j]);
      }
  }  
 
 printf("\nThe matrix is : \n");
  for(i=0;i<3;i++)
  {
      printf("\n");
      for(j=0;j<3;j++)
           printf("%d\t",arr1[i][j]);
  }
 printf("\n\n");
}
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...