Design a game in c, C/C++ Programming

Design a game in c:

const DODGERS = 0;

const GIANTS = 1;

 

void main(void)

{

   int scoreboard [2][9];    // An array two rows by nine columns

   int team, inning;

   int score, total;

 

   randomize();              // Initialize random number generator

 

   // Generate the scores

   for (team = DODGERS; team <= GIANTS; team++) {

      for (inning = 0; inning < 9; inning++) {

         score = random(3);

         if (score == 2)             // 1/3 chance to score at least a run

            score = random(3) + 1;   // 1 to 3 runs

         if (score == 3)

            score = random(7) + 1;   // Simulates chance of a big

                                     // inning of 1 to 7 runs

         scoreboard[team][inning] = score;

      }

   }

 

   // Print the scores

   cout << "\nInning\t1   2   3   4   5   6   7   8   9  Total\n";

   cout << "Dodgers\t";

   total = 0;

   for (inning = 0; inning <= 8; inning++) {

      score = scoreboard[DODGERS][inning];

      total += score;

      cout << score << "   ";

   }

   cout << total << "\n";

 

   cout << "Giants\t";

   total = 0;

   for (inning = 0; inning < 9; inning++) {

      score = scoreboard[GIANTS][inning];

      total += score;

      cout << score << "   ";

   }

   cout << total << "\n" ;

}

 

 

Posted Date: 10/18/2012 7:52:24 AM | Location : United States







Related Discussions:- Design a game in c, Assignment Help, Ask Question on Design a game in c, Get Answer, Expert's Help, Design a game in c Discussions

Write discussion on Design a game in c
Your posts are moderated
Related Questions
Can a copy constructor admit an object of the similar class as parameter, rather than reference of the object?

Prepare an Application in C# or C++ Project Description: We are seeking someone who can write a program in C# or C++. The idea is to prepare the program using a Cross Plat

WHAT IS CGI?

At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers

What are all of the implicit member functions of the class? Or what are all of the functions that compiler implements for us if we don't describe one? A: 1.      copy ctor

code for solving optimal solution for matrix

Explain the Working of strcpy Function? strcpy() : This function is meant to use to copy one string to another. The strcpy function as well accepts two strings as arguments.

Question: (a) Explain a linked list. (b) Describe the three different types of linked list with the help of diagrams. (c) Give two advantages and two disadvantages

C program to check display days and month main() {           int months, days;           clrscr();           printf("ENTER DAYS: ");           scanf("%d", &days);

.Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b.