How would you dynamically allocate a 2-D array of integers?5
1021 5b5cc7dce4d2b419777515bd
Q: How would you dynamically allocate a 2-D array of integers?
- उत्तर देखें
- Workspace
- चर्चा
Answer :
Explanation :
#include "alloc.h" #define MAXROW 3 #define MAXcol 4 main() { int *p, i, J; p = (int *) malloc (MAXROW * MAXCOL * sizeof (int)); for ( i=0; i < MaxROW ; i++) { for (j=0; j < MAXCOL ; j++) { p [ i * MAXCOL + j] = i; printf ( "%d", p [i * MAXCOL + j] ); } printf ("\n"); } }
समान प्रश्न
Since Nithya and Suganya exchange places, so Rita’s new position is the same as Monika’s earlier position. This position is 17th from the right and 10th from the left. Therefore Number of girls in the row = (16 + 1 + 9) = 26.