Thread: meaningful example of array

  1. #1
    Registered User
    Join Date
    Oct 2022
    Posts
    90

    meaningful example of array

    Hey Guys

    I can declare and assign a values to multidimensional array but I don't find real life example in daily use


    Code:
     #include<stdio.h>
    
    int main ()
    {	
    	int N [3][2][2] = { { {1, 2}, {3, 4}}, {{5, 6}, {7, 8}}, { {9, 10}, {11, 12}} };
    	
    	return 0;
    }
    Can anyone give one real life example of multidimensional array ?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Here's one - you have rainfall data for several years.
    Code:
    #define N_YEARS 10
    #define N_MONTHS 12
    #define N_DAYS 31  // the max for convenience
    int rainfall[N_YEARS][N_MONTHS][N_DAYS];
    Then if you had multiple locations, it might be.
    Code:
    #define N_LOCS 5
    #define N_YEARS 10
    #define N_MONTHS 12
    #define N_DAYS 31  // the max for convenience
    int rainfall[N_LOCS][N_YEARS][N_MONTHS][N_DAYS];
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Patterns to produce "meaningful" patterns
    By Aslaville in forum Tech Board
    Replies: 5
    Last Post: 03-14-2015, 12:46 AM
  2. Replies: 2
    Last Post: 03-20-2012, 08:41 AM
  3. How to convert this into a meaningful timestamp
    By m37h0d in forum C++ Programming
    Replies: 4
    Last Post: 10-16-2009, 12:44 PM
  4. mktime() doesn't return meaningful value!
    By patiobarbecue in forum C Programming
    Replies: 5
    Last Post: 12-19-2008, 07:06 AM
  5. The Meaningful C++ FAQ
    By Mario F. in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 06-05-2006, 11:13 AM

Tags for this Thread