-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path2D-to-1D-Array.c
More file actions
37 lines (37 loc) · 874 Bytes
/
2D-to-1D-Array.c
File metadata and controls
37 lines (37 loc) · 874 Bytes
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
#include<stdio.h>
#include<conio.h>
int main(){
int a[3][3],i,j,b[9],k=0;
printf("Enter Elements for 2D Array.......");
getch();
for(i=0;i<3;i++){
for(j=0;j<3;j++){
printf("\nEnter Element a[%d][%d] : ",i,j);
scanf("%d",&a[i][j]);
}
}
getch();
printf("\nThe Elements of 2D Array are....\n");
getch();
for(i=0;i<3;i++){
for(j=0;j<3;j++){
printf("a[%d][%d] = %d\t",i,j,a[i][j]);
getch();
}
}
printf("\nCopying into 1D Array.....");
for(i=0;i<3;i++){
for(j=0;j<3;j++){
b[k]=a[i][j];
k++;
}
}
getch();
printf("\nThe Elements of 1D Array are....\n");
getch();
for(k=0;k<9;k++){
printf("b[%d] = %d\t",k,b[k]);
getch();
}
return 0;
}