-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopyarr.c
More file actions
45 lines (44 loc) · 962 Bytes
/
copyarr.c
File metadata and controls
45 lines (44 loc) · 962 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
38
39
40
41
42
43
44
45
/*
Input the number of elements to be stored in the array :3
Input 3 elements in the array :
element - 0 : 15
element - 1 : 10
element - 2 : 12
Expected Output :
The elements stored in the first array are :
15 10 12
The elements copied into the second array are :
15 10 12
*/
#include <stdio.h>
int copyArray(int a[], int b[], int n)
{
int i;
for (i = 0; i < n; i++)
{
b[i] = a[i];
}
}
int main(void)
{
int i, n, a[100], b[100];
printf("Input the number of elements to be stored in the array :");
scanf("%d", &n);
for (i = 0; i < n; i++)
{
printf("Element -%d:", i);
scanf("%d", &a[i]);
}
printf("\nThe elements stored in the first array are :\n");
for (i = 0; i < n; i++)
{
printf("%d\n", a[i]);
}
copyArray(a, b, n);
printf("\nThe elements stored in the second array are :\n");
for (i = 0; i < n; i++)
{
printf("%d\n", b[i]);
}
return 0;
}