#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2011
    Posts
    10
    Rep Power
    0

    I badly need help to continue wiz my program below!!


    Every Saturday the draw is broadcast live on TV. The “LOTTO GAME” is played as
    follows:
    Six numbers between 1 and 40 inclusive are generated at random.
    If a number has been generated it is not generated a second time.
    A player can bet any six numbers between 1 and 40 inclusive.
    The cost for each bet is Rs 20. A player can bet as many times as he wishes for each
    draw. If the player gets all the six numbers correct (the order is not important) he wins the
    jackpot.
    If more than one player wins the six correct numbers the jackpot is shared equally among
    them. The program should be able to record all the players, their bet and the total bet. For
    five, four and three correct (again order is not important) betting consolation prizes are
    awarded. Obviously as the number of correct numbers decreases the number of potential
    winners increases and the prizes decrease also.
    Each time the game is played a completely new and random set of six numbers between
    1 and 40 inclusive are generated.


    Here is my code which i've done below but i could not continue further whatever the above question is asking me. I want a help!!

    int main()
    {
    int nums[6];
    int i,j;
    printf("Enter six numbers between 1 and 40\n");

    for(i=0;i<6;i++){
    scanf("%d",&nums[i]);
    if(nums[i]<=0 || nums[i]>=41){
    printf("The number you have entered is not between 1 and 40\n");
    getch();
    exit(0);
    }
    for(j=0;j<i;j++)
    if(nums[i]==nums[j]){
    printf("Wow Wow you have repeated the number\n");
    getch();
    exit(0);
    }
    }

    Comments on this post

    • LittleGrin disagrees : This is about the fourth time you've created a thread about this problem, in this forum (including threads moderators have removed). Do some actual work for yourself
    • SimonB2 disagrees : GTFO of here. Can't format a post, can't read directions, won't play nice with others.
  2. #2
  3. Commie Mutant Traitor
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2004
    Location
    Alpharetta, GA
    Posts
    1,809
    Rep Power
    1574
    While your insistence on repeatedly posting of the same material probably means you aren't actually reading these responses, I'll be kind and re-post your code with [code] tags. Please, please, please use them in the future, here and elsewhere.
    Code:
    int main()
    {
      int nums[6];
       int i,j;
       printf("Enter six numbers between 1 and 40\n");
    
       for(i=0;i<6;i++){
         scanf("%d",&nums[i]);
         if(nums[i]<=0 || nums[i]>=41){
           printf("The number you have entered is not between 1 and 40\n");
           getch();
           exit(0);
         }
         for(j=0;j<i;j++)
           if(nums[i]==nums[j]){
             printf("Wow Wow you have repeated the number\n");
             getch();
             exit(0);
         }
       }
    I'll also point out a few of the problems with the program as given.

    First off, you didn't add (or perhaps just omitted) the #include directives for the standard libraries, which means that the code as given will not compile correctly.

    Second, you do not close the first for() loop, meaning (again) that the code won't compile as given. I believe that the loop you wanted should have a second close brace just after the one closing the if() statement:
    Code:
       for(i=0;i<6;i++){
         scanf("%d",&nums[i]);
         if(nums[i]<=0 || nums[i]>=41){
           printf("The number you have entered is not between 1 and 40\n");
           getch();
           exit(0);
         }
       }
    Third, you need something to generate the random numbers you need. The functions srand() and rand() are normally used for this purpose; I suggest you read the documentation on them to see how they are used (I know that the links go to pages about C++, but in this case both C and C++ work more or less the same way, modulo the header files).

    This is your last chance here. Don't screw it up.

    Comments on this post

    • SimonB2 agrees
    Rev First Speaker Schol-R-LEA;2 JAM LCF ELF KoR KCO BiWM TGIF
    #define KINSEY (rand() % 7) λ Scheme is the Red Pill
    Scheme in ShortUnderstanding the C/C++ Preprocessor
    Taming PythonA Highly Opinionated Review of Programming Languages for the Novice, v1.1

    FOR SALE: One ShapeSystem 2300 CMD, extensively modified for human use. Includes s/w for anthro, transgender, sex-appeal enhance, & Gillian Anderson and Jason D. Poit clone forms. Some wear. $4500 obo. tverres@et.ins.gov

IMN logo majestic logo threadwatch logo seochat tools logo