C Program to copy all elements of an array to another array


In this program, You will learn how to copy all elements of an array to another array in c.


List is: 1, 2, 12, 23, 12, 23


Example: How to copy all elements of an array to another array in c

Run it Now
#include<stdio.h>

int main() {

   int arr1[10], arr2[10], i, n;

   printf("Enter Size of an Array :");
   scanf("%d", &n);

   printf("\nEnter Array Elements :");
   for (i = 0; i < n; i++) {
       scanf("%d", &arr1[i]);
   }

   for (i = 0; i < n; i++) {
       arr2[i] = arr1[i];
   }

   printf("\nCopy Array List is :");
   for (i = 0; i < n; i++) {
       printf("%d ", arr2[i]);
   }

   return 0;
}

Output:

Enter Size of an Array :5
Enter Array Elements :11 22 33 44 55
Copy Array is :11 22 33 44 55