The ones who are crazy enough to think they can change the world are the ones who do.- Steve Jobs
An array having more than one subscript or dimension is known as multi dimensional array i.e) int arr[3][3]. Multi dimensional arrays are also known as arrays of arrays or matrix.
data-type varname [size1][size2];
Consider a specific example. Suppose that you have a extreme interest in the whether, and you are intent on recording the temperature each day at 2 separate geographical locations throughout the year. After you have sorted out the logistics of actually collecting this information, you can use an array of 2 elements corresponding to the number of locations, where each of these elements in an array of 4 elements to store the temperature values.
#include <stdio.h> int main() { float temp[2][4] = {{12.31, 14.36, 13.4, 12.4}, {11.2, 11.24, 14.2, 12.5}}; int i, j; for(i = 0; i < 2; i++) { for(j = 0; j < 4; j++) { printf("\nTemperature @ location %d ---> %f (%d time) ",i+1, temp[i][j] ,j+1); } } return 0; }
The above program clearly demonstrates the concept of two dimensional array.
We may make mistakes(spelling, program bug, typing mistake and etc.), So we have this container to collect mistakes. We highly respect your findings.
© Copyright 2019