Question: int main ( ) { / / Create an array of ships Ship ships [ ] = { { Carrier , 0 ,

int main(){// Create an array of ships Ship ships[]={{"Carrier",0,0},{"Battleship",1,1},{"Cruiser",2,2},{"Submarine",3,3},{"Destroyer",4,4}}; //(b) Copy the ships array to a new array called ships_new Ship ships_new[5]; memcpy(ships_new, ships, sizeof(ships)); //(c) Modify ships_new to reflect the changes // Change the type of the Cruiser to "Destroyer" strcpy(ships_new[2].type, "Destroyer"); // Change the old Destroyer to "Patrol Boat" strcpy(ships_new[4].type, "Patrol Boat"); // Move the Submarine 2 units in the +y direction ships_new[3].y +=2; // Print the modified ships_new array for (int i =0; i <5; i++){ printf("Ship Type: %s, Position: (%d,%d)
", ships_new[i].type, ships_new[i].x, ships_new[i].y); } return 0;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!