C Programming Code Examples C > Arrays and Matrices Code Examples program to copy all elements of one array to another program to copy all elements of one array to another Write a C program to read elements in array and copy all elements of first array into second array. C program to copy elements of array. Logic to copy array elements to another array using C program. Input size and elements in array, store it in some variable say size and first. Declare another to store copy of the first array, say second. Now, to copy all elements from first to second array, you just need to run loop through each elements of first array. Run a loop from 0 to size of the array. The loop structure should look like for(x=0; x<size; x++). Inside the loop assign the current element value of first array to second i.e. second[x] = first[x]. #include <stdio.h> #include maxsize 100 int main() { int first[maxsize], second[maxsize]; int x, size; /* Input size of the array */ printf("Enter the size of the array : "); scanf("%d", &size); /* Input array elements */ printf("Enter elements of first array : "); for(x=0; x<size; x++) { scanf("%d", &first[x]); } /* Copy all elements from first array to second array */ for(x=0; x<size; x++) { second[x] = first[x]; } /* Print all elements of first array */ printf("\nElements of first array are : "); for(x=0; x<size; x++) { printf("%d\t", first[x]); } /* Print all elements of second array */ printf("\nElements of second array are : "); for(x=0; x<size; x++) { printf("%d\t", second[x]); } return 0; }