C PROGRAMMING

write a c program to copy elements of one array to another

C program to copy elements of one array to another array?

  #include<stdio.h>

main()

{
int arr1[30], arr2[30], i, num;
printf("nEnter size of array elements :");
scanf("%d", &num);
for (i = 0; i < num; i++)
{
printf("nEnter the %d value:",i+1);
scanf("%d", &arr1[i]);
}

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

printf("The copied array is :");
for (i = 0; i < num; i++)
printf("%d ", arr2[i]);
getch();
}

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button