Program
#include <stdio.h> int main() { printf("****************************************************"); printf("\n****************************************************"); printf("\n** WAP to enter and display a 2D array **"); printf("\n** Created by Sheetal Garg **"); printf("\n** Assistant Professor **"); printf("\n** Phone No:9467863365 **"); printf("\n****************************************************"); printf("\n****************************************************\n"); int m, n, i, j, a[5][5]; printf("Enter no. of rows and columns in the array\n"); scanf("%d%d", &m, &n); printf("enter array elements"); for (i = 0; i < m; i++) for (j = 0; j < n; j++) scanf("%d", &a[i][j]); printf("\nThe array elements are\n"); for (i = 0; i < m; i++) { for (j = 0; j < n; j++) printf("%d\t", a[i][j]); printf("\n"); } return 0; }
Output
**************************************************** **************************************************** ** WAP to enter and display a 2D array ** ** Created by Sheetal Garg ** ** Assistant Professor ** ** Phone No:9467863365 ** **************************************************** **************************************************** Enter no. of rows and columns in the array 3 3 enter array elements 2 4 5 3 4 6 7 5 2 The array elements are 2 4 5 3 4 6 7 5 2