Initialization of a multidimensional arrays in C/C++ Program


In this tutorial, we will be discussing a program to understand how to initiate a multidimensional array in C/C++.

While declaring a multidimensional array, the value of the leftmost dimension can be left empty, but all other dimensions must be provided.

Example

 Live Demo

#include<stdio.h>
int main(){
   int a[][2] = {{1,2},{3,4}};
   printf("%lu", sizeof(a));
   getchar();
   return 0;
}

Output

16

Updated on: 23-Mar-2020

105 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements