Required knowledge:
Basic C programming, For loop, ArrayProgram:
/** * C program to copy one array to another array */ #include <stdio.h> int main() { int first[100], second[100]; int i, size; /* * Reads size and elements in the array from user */ printf("Enter the size of the array : "); scanf("%d", &size); printf("Enter elements of first array : "); for(i=0; i<size; i++) { scanf("%d", &first[i]); } /* * Copies all elements from first array to second array */ for(i=0; i<size; i++) { second[i] = first[i]; } /* * Prints all elements of first array */ printf("\nElements of first array are : "); for(i=0; i<size; i++) { printf("%d\t", first[i]); } /* * Prints all elements of second array */ printf("\nElements of second array are : "); for(i=0; i<size; i++) { printf("%d\t", second[i]); } return 0; }
Output
Enter the size of the array : 10
Enter elements of first array : 10 20 30 40 50 60 70 80 90 100
Elements of first array are : 10 20 30 40 50 60 70 80 90 100
Elements of second array are : 10 20 30 40 50 60 70 80 90 100
Enter elements of first array : 10 20 30 40 50 60 70 80 90 100
Elements of first array are : 10 20 30 40 50 60 70 80 90 100
Elements of second array are : 10 20 30 40 50 60 70 80 90 100
Happy coding ;)
You may also like
- Array and Matrix programming exercises index.
- C program to read and print elements in array.
- C program to find sum of all array elements.
- C program to find maximum and minimum elements in array.
- C program to print all natural numbers from 1 to n.
- C program to find reverse of any number.
- C program to check whether a number is palindrome or not.
- C program to find factorial of any number.
- C program to find transpose of a matrix.
- C program to check Armstrong number.
- C program to check Strong number.
- C program to check Perfect number.
- C program to check Identity matrix.
- C program to check Sparse matrix.
- C program to check Symmetric matrix.