Copy One Array to Another
C++
Easy
5 views
Problem Description
Description: Write code to copy all elements from one array to another array. This demonstrates basic array manipulation and memory concepts.
Logic: Iterate through source array and assign to destination
Official Solution
void question3_copy_array() {
int source[] = {10, 20, 30, 40, 50};
int destination[5];
int size = 5;
for(int i = 0; i < size; i++) {
destination[i] = source[i];
}
cout << "Copied array: ";
for(int i = 0; i < size; i++) {
cout << destination[i] << " ";
}
cout << endl;
}
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!