1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
#include<stdio.h>
#include<math.h>
#define ARRLENG 8
#define ARRCOL 4
#define ARRROW 2
int main()
{
int i, r, myArr[ARRLENG]={1, 12, 23, 0, -1, -12, -23, 289}, my2DArr[ARRROW] [ARRCOL];
printf("The Data in my Arr are:\n");
for (i=0; i<8; i++)
{
printf("%d ",myArr[i]);
}
printf("\n\nThe Data in my2DArr are\n");
/*this part not working*/
for (r=0; r<4; r++)
{
myArr[r]= my2DArr[1] [r];
printf("%3d ", my2DArr[1] [r]);
}
printf("\n");
for (r=4; r<8; r++)
{
myArr[r]= my2DArr[2] [r];
printf("%3d ", my2DArr[2] [r]);
}
int mynewarr[ARRLENG];
printf("\n\n\nEnter 8 integers for mynewarr:\n\n");
scanf("%d%d%d%d%d%d%d%d", &(mynewarr[1]),&(mynewarr[2]), &(mynewarr[3]),&(mynewarr[4]),&(mynewarr[5]), &(mynewarr[6]),&(mynewarr[7]), &(mynewarr[8]));
for (i=0; i<8; i++)
{
printf("%d ",mynewarr[i]);
}
return 0;
}
|