Program
#include <stdio.h> int main() { printf("****************************************************"); printf("\n****************************************************"); printf("\n** WAP to find product of elements of 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], p = 1; printf("Enter no. of rows and columns in the array\n"); scanf("%d%d", &m, &n); printf("enter array elements\n"); for (i = 0; i < m; i++) for (j = 0; j < n; j++) { scanf("%d", &a[i][j]); p = p * 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"); } printf("\nThe product of elements is %d", p); return 0; }
Output
**************************************************** **************************************************** ** WAP to find product of elements of 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 1 2 2 2 1 3 2 2 1 The array elements are 1 2 2 2 1 3 2 2 1 The product of elements is 96