Viết chương trình C để copy các phần tử mảng

Các bước thực hiện để viết chương trình C:

1. Nhập vào kích thước mảng (số phần tử mảng) size

2. Nhập vào các giá trị của mảng nguồn source

3. Copy toàn bộ phần tử của mảng nguồn source sang mảng đích dest

4. Dùng vòng lặp để in ra toàn bộ phần tử của mảng nguồn source

5. Dùng vòng lặp để in ra toàn bộ phần tử của mảng đích dest

Code tham khảo của chương trình C:

#include <stdio.h>
#define MAX_SIZE 100

int main()
{
int source[MAX_SIZE], dest[MAX_SIZE];
int i, size;

/*1. Input size of the array */
printf("Enter the size of the array : ");
scanf("%d", &size);
/*2. Input source array elements */
printf("Enter elements of source array : ");
for(i=0; i<size; i++)
{
scanf("%d", &source[i]);
}

/*3. Copy all elements from source array to dest array*/
for(i=0; i<size; i++)
{
dest[i] = source[i];
}

/*4. Print all elements of source array */
printf("\nElements of source array are : ");
for(i=0; i<size; i++)
{
printf("%d\t", source[i]);
}

/*5. Print all elements of dest array*/
printf("\nElements of dest array are : ");
for(i=0; i<size; i++)
{
printf("%d\t", dest[i]);
}
return 0;
}