Computer Science, asked by seemadkhan66, 14 days ago

Write a program to input float type data into a table having 5 rows and 4 columns. Find out the maximum number entered in the table and print it out on the screen.

Answers

Answered by ItzMrVinay
1

Answer:

Explanation:

An array of arrays is known as 2D array. The two dimensional (2D) array in C programming is also known as matrix. A matrix can be represented as a table of rows and columns. Before we discuss more about two Dimensional array lets have a look at the following C program.

Simple Two dimensional(2D) Array Example

For now don’t worry how to initialize a two dimensional array, we will discuss that part later. This program demonstrates how to store the elements entered by user in a 2d array and how to display the elements of a two dimensional array.

#include<stdio.h>

int main(){

/* 2D array declaration*/

int disp[2][3];

/*Counter variables for the loop*/

int i, j;

for(i=0; i<2; i++) {

for(j=0;j<3;j++) {

printf("Enter value for disp[%d][%d]:", i, j);

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

}

}

//Displaying array elements

printf("Two Dimensional array elements:\n");

for(i=0; i<2; i++) {

for(j=0;j<3;j++) {

printf("%d ", disp[i][j]);

if(j==2){

printf("\n");

}

}

}

return 0;

}

Output:

Enter value for disp[0][0]:1

Enter value for disp[0][1]:2

Enter value for disp[0][2]:3

Enter value for disp[1][0]:4

Enter value for disp[1][1]:5

Enter value for disp[1][2]:6

Two Dimensional array elements:

1 2 3

4 5 6

Initialization of 2D Array

There are two ways to initialize a two Dimensional arrays during declaration.

int disp[2][4] = {

{10, 11, 12, 13},

{14, 15, 16, 17}

};

OR

int disp[2][4] = { 10, 11, 12, 13, 14, 15, 16, 17};

Although both the above declarations are valid, I recommend you to use the first method as it is more readable, because you can visualize the rows and columns of 2d array in this method.

Things that you must consider while initializing a 2D array

We already know, when we initialize a normal array (or you can say one dimensional array) during declaration, we need not to specify the size of it. However that’s not the case with 2D array, you must always specify the second dimension even if you are specifying elements during the declaration. Let’s understand this with the help of few examples –

/* Valid declaration*/

int abc[2][2] = {1, 2, 3 ,4 }

/* Valid declaration*/

int abc[][2] = {1, 2, 3 ,4 }

/* Invalid declaration – you must specify second dimension*/

int abc[][] = {1, 2, 3 ,4 }

/* Invalid because of the same reason mentioned above*/

int abc[2][] = {1, 2, 3 ,4 }

Answered by utkarsh2choirasiya
0

Answer:

kkkkkkkkkkkkk

Explanation:

kkkkkkkkkkkkk

Similar questions