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

C++Server Side ProgrammingProgramming

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
raja
Published on 23-Mar-2020 08:38:28
Advertisements