Question: creating an 2D array for my battleship game. Here what i have so far: #include using namespace std; const int ROWS = 10; const int

creating an 2D array for my battleship game. Here what i have so far:

#include

using namespace std;

const int ROWS = 10;

const int COLS = 10;

int main()

{

char board[ROWS][COLS];

for(int i = 0; i < ROWS; i++)

{

for(int j = 0; j < COLS; j++)

{

board[i][j] = '|';

}

}

for(int i = 0; i < ROWS; i++)

{

for(int j=0; j < COLS; j++)

cout << board[i][j] << " ";

cout << endl;

}

}

Here is the output that i need:

Enter firing coordinates !!! A 5

Hit !!!

Current Status

1 2 3 4 5 6 7 8 9 10

A | | | | | X | | | | | |

B | | | | | | | | | | |

C | | | | | | | | | | |

D | | | | | | | | | | |

E | | | | | | | | | | |

F | | | | | | | | | | |

G | | | | | | | | | | |

H | | | | | | | | | | |

I | | | | | | | | | | |

J | | | | | | | | | | |

Ammo remaining : 19

I need help creating rows A-J and Columns 1-10 so that when somone types in A 6, the X will go into the correct row/column

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 Databases Questions!