1. Engineering
  2. Computer Science
  3. im making a simple battleship game in c for my...

Question: im making a simple battleship game in c for my...

Question details

I'm making a simple Battleship game in C for my programing class. The first part of the assignment is quite simple. I just need to make the welcome screen function displaying the rules of the game. The instructions are as follows.

  1. Create a new C source code file names battleship.c
  1. Write the preprocessor command to include the stdio.h header file from the C library
  2. Write the function declaration or prototype for function welcomeScreen (hint: it is the same method signature of the function with a semi-colon at the end)
  3. Write the main function so it does the following
    1. Return type int
    2. Empty parameter list
    3. Calls function welcomeScreen
    4. Returns 0 to indicate successful operation of the program
  4. Write the function welcomeScreen so it does the following
    1. Return type void
    2. Empty parameter list
    3. Outputs to the screen the name of the game and the instructions.

I've already created the printf statements needed for the welcome screen. They are as follows. The first few may look a bit weird because of the way this question bar works, but they just spell BATTLESHIP in smaller letters.

    printf ("BBBBB   AAAA TTTTTT TTTTTT LL     EEEEEE SSSSS HH HH II PPPP\n");
   printf ("BB BB AA AA   TT     TT   LL     EE     SS     HH HH II PP PP\n");
   printf ("BBBBB AA AA   TT     TT   LL     EEEE    SSSS HHHHHH II PPPP\n");
   printf ("BB BB AAAAAA   TT     TT   LL     EE         SS HH HH II PP\n");
   printf ("BBBBB AA AA   TT     TT   LLLLLL EEEEEE SSSSS HH HH II PP\n");
   printf ("\n\n");
   printf ("RULES OF THE GAME:\n");
   printf ("1. This is a two player game.\n");
   printf ("2. Player 1 is you and Player 2 is the computer.\n");
   printf ("3. Player 1 will be prompted if user wants to manually input coordinates\n");
   printf ("   for the game board or have the computer randomly generate a game board\n");
   printf ("4. There are five types of ships to be placed by longest length to the\n");
   printf ("   shortest; [c] Carrier has 5 cells, [b] Battleship has 4 cells, [r] Cruiser\n");
   printf ("   has 3 cells, [s] Submarine has 3 cells, [d] Destroyer has 2 cells\n");
   printf ("5. The computer randomly selects which player goes first\n");
   printf ("6. The game begins as each player tries to guess the location of the ships\n");
   printf ("   of the opposing player's game board; [*] hit and [m] miss\n");
   printf ("7. First player to guess the location of all ships wins\n\n");

All I need is someone to show me what the finished product should look like. Please read the above instructions carefully. The program must also include a detailed comment explaining the function prototype and the function's purpose (to create a welcome screen for the game). Please include the full program in C.

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution