COPY CODE SNIPPET

C program to display contents of 2d array

display contents of 2d array


  1. # include<stdio.h>
  2. main()
  3. {
  4.     int arr[2][2]={            // Two dimensional array declaration.
  5.      {1,2},
  6.      {3,4}
  7. };
  8. int i=0,j=0;
  9. clrscr();
  10. printf("\n Array contents are:\n");
  11. for(i=0;i<=1;i++) // Outer for loop to count number of rows.
  12. {
  13.     for(j=0;j<=1;j++) // Inner for loop to count number of rows
  14.     {
  15.     printf("arr[%d][%d]=%d\t", i,j,arr[i][j]);
  16.     }
  17.     printf("\n");      // New line for each row.
  18. }
  19. getch();
  20. }
C program to display contents of 2d array  C program to display contents of 2d array Reviewed by Unknown on 17:12 Rating: 5

No comments:

COPY CODE SNIPPET
Powered by Blogger.