C program to enter 2-D array elements and display on screen

 C program to enter 2-D array elements and display on screen


/*******************************************

 C program to enter 2-D array elements and display on screen

 **************************************************/

#include<stdio.h>

#include<conio.h>

void main()

{

    int a[20][20];

    int i, j,n,m;

    printf("How many rows and columns\n");

    scanf("%d%d",&n,&m);

    printf("Enter array elements\n");

    for(i=0;i<n;i++)

    {

        for(j=0;j<m;j++)

        {

            scanf("%d",&a[i][j]);

        }

    }

    printf("\n");

    printf("Following is %d X %d array\n",n,m);

    for(i=0;i<n;i++)

    {

        for(j=0;j<m;j++)

        {

            printf("%d\t",a[i][j]);

        }

        printf("\n");

    }

    printf("End of program");

    getch();

}

How many rows and columns

3

4

Enter array elements

1

2

3

4

5

6

7

8

9

10

11

12


Following is 3 X 4 array

1 2 3 4

5 6 7 8

9 10 11 12

End of program


टिप्पणी पोस्ट करा

0 टिप्पण्या