Thread: Lotto game in C

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    2

    Lotto game in C

    For our homework, we have to write a program that simulates a lottery, randomly drawing 3 balls numbered 1 through 10. The user inputs the # of drawings. What I don't get is how to show the percentage of times the number(s)drawn are 7, 1 2 & 3, or even numbers. Can anyone give me any suggestions on how to do counters to show these percentages. This code works except for doing the percentages.
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    main()
    {
         unsigned int seed;
         int a=1, b=10, k;
         int rand_int(int a, int b);
         int numDraw;
    	
         printf("Enter number of Lottery Drawings to simulate:  ");
         scanf("%i", &numDraw);
    
         printf("\nEnter a positive integer seed value: ");
         scanf("%u",&seed);
         srand(seed);
    
         while (numDraw > 0)
         {
              for (k=1; k<=3; k++)
              {
                    printf("%i  ",rand_int(a,b));
              }
              printf("\n");
              numDraw--;
         }
    return 0;
    }
       
    int rand_int (int a, int b)
    {
         return rand()%(b-a+1) + a;
    }
    Last edited by fun2sas; 03-02-2003 at 07:07 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do the game engine and the api interact?
    By Shadow12345 in forum Game Programming
    Replies: 9
    Last Post: 12-08-2010, 12:08 AM
  2. game engine advice?
    By stien in forum Game Programming
    Replies: 0
    Last Post: 01-23-2007, 03:46 PM
  3. 2D RPG Online Game Project. 30% Complete. To be released and marketed.
    By drallstars in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 10-28-2006, 12:48 AM
  4. C++ Game of Life Program
    By rayrayj52 in forum C++ Programming
    Replies: 16
    Last Post: 09-26-2004, 03:58 PM
  5. My Maze Game --- A Few Questions
    By TechWins in forum Game Programming
    Replies: 18
    Last Post: 04-24-2002, 11:00 PM