'Adding a header to a 2d array
Tried this but does not work as intended:
#include <stdio.h>
int main()
{
int arr[2][2] = {10,11,12,13};
int i,j;
for(i = 0; i<2; i++)
{
printf("ds%d",i+1);
printf("\n");
for(j = 0; j<2; j++)
{
printf("%d\t", arr[i][j]);
}
}
return 0;
}
The result that appeared:
ds1
10 11 ds2
12 13
The needed result should be the following:
ds1 ds2
10 11
12 13
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
