C Program to copy contents of one array to another
Program
#include<stdio.h>
void main()
{
int source_arr[30], dest_arr[30], i, num;
printf("Enter no of elements:\t");
scanf("%d", &num);
printf("Enter the values to the array:\n");
for (i = 0; i < num; i++)
{
scanf("%d", &source_arr[i]);
}
for (i = 0; i < num; i++)
{
dest_arr[i] = source_arr[i];
}
printf("The copied array is:\n");
for (i = 0; i < num; i++)
printf("%d\n", dest_arr[i]);
}
Output
Enter no of elements: 6
Enter the values to the array:
12
43
22
98
56
76
The copied array is:
12
43
22
98
56
76