Created on 2/1/2018
A piece of code that stores the entered Battle Ship information and performs simple calculations.
This simple program is written in C language. It will:
- Ask the user to input the information into an array of structure.
- Display the ships as the original order in a table-like format;
- Calculate the average values for numGuns and displacement, and display the result.
NAME | TYPE | COUNTRY | NUMGUNS | BORE | DISPLACEMENT |
---|---|---|---|---|---|
Bismarck | bb | Germany | 8 | 15 | 42000 |
North Carolina | bb | USA | 9 | 16 | 37000 |
Tennessee | bb | USA | 12 | 14 | 32000 |
- Open the Command Prompt
- Test if you have gcc installed by typing
gcc -v
. If it is not installed, please install gcc https://gcc.gnu.org/ - Go to the source code directory
- Compile the source code
gcc -o program BattleShip.c
- Run your program
program
- Open terminal
- Install the command-line tools:
xcode-select --install
- Go to the source code directory
- Compile the source code
gcc -Wall -o program BattleShip.c
- Run your program
./program