Initializing Multidimensional Arrays in single dimensional format - C++ Data Type

C++ examples for Data Type:Array

Description

Initializing Multidimensional Arrays in single dimensional format

Demo Code

#include <iostream> 
  
int main() //from   www .j  ava  2  s. co  m
{ 
    int box[5][3] = { 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15 }; 

    for (int i = 0; i < 5; i++) 
    { 
           for (int j = 0; j < 3; j++) 
           { 
                std::cout << "box[" << i << "]"; 
                std::cout << "[" << j << "] = "; 
                std::cout << box[i][j] << "\n"; 
           } 
    } 
}

Result


Related Tutorials