Multidimensional Array_1.6

#include <stdio.h>
int main()
{
    int a[25][25],i,j,k=5;
    for(i=1;i<=5;i++)
    {
      for(j=1;j<=i;j++)
      {
         a[i][j]=k;
         k--;
      }
      k=5;
    }

    for(i=1;i<=5;i++)
    {
      for(j=1;j<=i;j++)
      {
          printf("%2d",a[i][j]);
      }
          printf("\n");
    }
    system("pause");
    return 0;
}

This is the output:
 5
 5 4
 5 4 3
 5 4 3 2
 5 4 3 2 1

0 comments:

Post a Comment