printf("\n  How much you tickets you want to bet(Rs20 per ticket): ");
   scanf("%i",&bet);
   
   int x=0;
   for (x=0;x<bet;x++)
      {
      printf("\n  Enter the 6 numbers ( 1 - 40): ");
      // int num/*concatenate x */[100]
       
  
    for( i=0;i<6;i++)                    

        scanf("%d",&num/*concatenate x */[i]);             // Storing the values inserted into array num 
   }

Suppose i got this code, i want to create an array for each player to insert their numbers,i want to name the array as num1, num2,num3....

how do i concatenate the value to the array name ?

You don't want to do it that way. Use an array instead, where you would otherwise be tempted for name1, name2, name3, ..., nameN variables:

int (*tickets)[6] = malloc(bet * sizeof *tickets);

for (int x = 0; x < bet; x++) {
    printf("Enter the 6 numbers ( 1 - 40): : ");
    fflush(stdout);
    
    for (int i = 0; i < 6; i++)
        scanf("%d", &tickets[x][i]);
}

...

free(tickets); /* Don't forget to release memory when you're done */

did u use a 2-dimensional array ??

tickets[x] ?

and can u tel me wat these 2 lines do

fflush(stdout);

int (*tickets)[6] = malloc(bet * sizeof *tickets);

did u use a 2-dimensional array ??

I used something close enough.

fflush(stdout);

The output stream's internal buffer is only flushed in three cases:

  • The buffer is full.
  • A newline character is written.
  • fflush() is called on the stream.

Since you don't have control over when the buffer becomes full, the only two ways the programmer can force a flush is by writing a newline or calling fflush(). If the behavior isn't conducive to writing a newline, such as an interactive prompt where input should be on the same line as the prompt, the only option is calling fflush().

The reason I do this is that without a flush there's no guarantee that the prompt will be shown before scanf() blocks for input. In other words, the user won't know what to do.

int (*tickets)[6] = malloc(bet * sizeof *tickets);

I'm basically allocating memory for a two dimensional array. The second dimension is fixed at 6, so the type is a pointer to an array rather than a pointer to a pointer. This avoids making subsequent calls to malloc() for the second dimension, which is what would work best if the size of both dimensions were a runtime quantity:

int **tickets = malloc(bet * sizeof *tickets);

for (int x = 0; x < bet; x++)
    tickets[x] = malloc(n * sizeof *tickets[x]);

...

Hey mate, the codes worked well for the single player mode..
But when i implement the multi player mode, im having a problem..

// Defining the single function   
int single()
{
   system ("cls");                           // Clear the screen 
   
   display();                               // Calling the display function
   
   printf("\n  How much you tickets you want to bet (Rs20 per ticket): ");
   scanf("%i",&bet);
   
   int (*tickets)[6] = malloc(bet * sizeof *tickets);
   
   for ( x = 0; x < bet; x++) 
    {
        printf("\n  Enter the 6 numbers ( 1 - 40): : ");
        fflush(stdout);
         
        for ( i = 0; i < 6; i++)
        scanf("%d", &tickets[x][i]);
    }
    
   system ("cls");                       // Clear the screen 
   
   printf ("\n");
   printf ("\t* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
   printf ("\t*                                                               *\n");
   printf ("\t*   The 6 series numbers you selected:                          *\n");
   printf ("\t*   ----------------------------------                          *\n");
   printf ("\t*                                                               *\n");

   
   for ( x = 0; x < bet; x++) 
   {
       printf ("\t*");
       for( i=0;i<6;i++)
       printf ("%10d",tickets[x][i]);              // Printing the values from the array num
       printf ("\t*\n");
       printf ("\t*                                                               *\n");                                               
   }
   
   printf ("\t*                                                               *\n");
   printf ("\t*                                                               *\n");
   printf ("\t* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"); 
      
   printf ("\n");
   printf ("\t* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
   printf ("\t*                                                               *\n");
   printf ("\t*   The Winning outcomes are:                                   *\n");
   printf ("\t*   -------------------------                                   *\n");
   printf ("\t*                                                               *\n");
   
   // Seeding rand() with the current time
   srand((unsigned)time(NULL));      
       
   // Initialize seq to an ordered range 
   for ( i = 0; i < N; i++ )
   seq[i] = i;
         
   // Random shuffle 
   for ( i = 0; i < N - 1; i++ ) 
   {
    int r = ( rand() % ( N - i ) + 1 );
    int save = seq[i];
    seq[i] = seq[i + r];
    seq[i + r] = save;
   }
        
   printf ("\t*");
        
   // Test the sequence 
   for ( i = 0; i < 6; i++ )
   printf ( "%10d", seq[i] );
        
   printf ("\t*");
   printf("\n");
        
   printf ("\t*                                                               *\n");
   printf ("\t*                                                               *\n");
   printf ("\t* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
        
   // For comparison, Nested loops were used since the arrays are small
 for ( x = 0; x < bet; x++) 
   {   
       for (j = 0; j < 6; j++) 
       {
           for (i = 0; i < 6; i++) 
           {
                if (seq[i] == tickets[x][j]) 
               {
                  ++matches;
               }
            }
        }
        
        if (matches ==6)      // In case all the 6 numbers are correct
        {   
            printf("\n\n\t  Ticket ");
            printf("%i",x+1);
            printf("\n\n\t  --------");
            printf("\n\n\t  Congratulations!");
            printf("\n\n\t  Congratulations!");
            printf(" You won the jackpot!!");
            printf("\n\n\t  You won the Rs 100,000 !!");
            total=total+100000;           
        } 
       
       else if (matches ==5)      // In case there are 5 correct numbers
        {   
            printf("\n\n\t  Ticket ");
            printf("%i",x+1);
            printf("\n\n\t  --------");
            printf("\n\n\t  Congratulations!");
            printf(" You got %i",matches);
            printf(" correct numbers");
            printf("\n\n\t  You won Rs 10,000 !!");
            total=total+ 10000;   
        } 
       
       else if (matches ==4)      // In case there are 4 correct numbers
        {   
            printf("\n\n\t  Ticket ");
            printf("%i",x+1);
            printf("\n\n\t  --------");
            printf("\n\n\t  Congratulations!");
            printf(" You got %i",matches);
            printf(" correct numbers");
            printf("\n\n\t  You won Rs 5,000 !!");
            total=total+ 5000;   
        } 
       
       else if (matches ==3)      // In case there are 3 correct numbers
        {   
            printf("\n\n\t  Ticket ");
            printf("%i",x+1);
            printf("\n\n\t  --------");
            printf("\n\n\t  Congratulations!");
            printf(" You got %i",matches);
            printf(" correct numbers");
            printf("\n\n\t  You won Rs 1,000 !!");
            total=total+ 1000;       
        } 
        
       else if (matches ==2)      // In case there are 2 correct numbers
        {   
            printf("\n\n\t  Ticket ");
            printf("%i",x+1);
            printf("\n\n\t  --------");
            printf("\n\n\t  Congratulations!");
            printf(" You got %i",matches);
            printf(" correct numbers");
            printf("\n\n\t  You won Rs 500 !!"); 
            total=total+ 500;   
        } 
       
       else if (matches ==1)      // In case there is 1 correct number
        {   
            printf("\n\n\t  Ticket ");
            printf("%i",x+1);
            printf("\n\n\t  --------");
            printf("\n\n\t  Congratulations!");
            printf(" You got %i",matches);
            printf(" correct numbers");
            printf("\n\n\t  You won Rs 100 !!");
            total=total+ 100;            
        } 
          
       else if (matches ==0)     // In case there is no correct number 
        {
            printf("\n\n\t  Ticket ");
            printf("%i",x+1);
            printf("\n\n\t  --------");
            printf("\n\n\t  Sorry no correct numbers, try your luck again!");  
        }   
         
        matches=0;           // Reseting the variable matches to 0             
  }
         printf ("\n\n");
         printf ("\t* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
         printf ("\t*                                                               *\n");
         printf ("\t*                                                               *\n");
         
         total=total+ money;  
         play = bet*20;
         printf("\t*  You played for Rs ");  
         printf("%d",play); 
         printf(" and won Rs ");   
         printf(" %d",total);
         printf("\t\t\t\t*\n");
         printf ("\t*                                                               *\n");
         printf ("\t*                                                               *\n");
         printf ("\t* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
  
  check();                 // Calling the input function
  free(tickets);           // Releasing the memory    
}

The problem is that in the multi player mode, the program will ask the user how many players there are, then it will the loop the single player mode function for the "number of players" times..

I tried to put the loop, but its not working coz of the 2-D array i think.. can u chek it plss..

int multi()
{
   system ("cls");                           // Clear the screen 
   
   display();                               // Calling the display function
   
   printf("\n  Number of players to play the game: ");
   scanf("%i",&players);
   
   printf("\n  How much you tickets you want to bet(Rs20 per ticket): ");
   scanf("%i",&bet);
 
   
   
   for ( y = 0; y < players; y++) 
   {  
       int (*tickets)[6] = malloc(bet * sizeof *tickets);
        printf("\n For Payer ");  
         printf("%d",y+1); 
            printf(": \n");
   for ( x = 0; x < bet; x++) 
    {
            
     
         
        printf("Enter the 6 numbers ( 1 - 40): : ");
        fflush(stdout);
         
        for ( i = 0; i < 6; i++)
        scanf("%d", &tickets[x][i]);
    }
}
   system ("cls");                       // Clear the screen 
   
   printf ("\n");
   printf ("\t* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
   printf ("\t*                                                               *\n");
   printf ("\t*   The 6 series numbers you selected:                          *\n");
   printf ("\t*   ----------------------------------                          *\n");
   printf ("\t*                                                               *\n");

    for ( y = 0; y < players; y++) 
   {  
   for ( x = 0; x < bet; x++) 
   {
        printf("\n For Payer ");  
         printf("%d",y+1); 
     
       printf ("\n\t*");
       for( i=0;i<6;i++)
       
       printf ("%10d",tickets[x][i]);              // Printing the values from the array num
       printf ("\t*\n");
       printf ("\t*                                                               *\n");                                               
   }
}
   printf ("\t*                                                               *\n");
   printf ("\t*                                                               *\n");
   printf ("\t* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
  
      
   printf ("\n");
   printf ("\t* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
   printf ("\t*                                                               *\n");
   printf ("\t*   The Winning outcomes are:                                   *\n");
   printf ("\t*   -------------------------                                   *\n");
   printf ("\t*                                                               *\n");
   
   // Seeding rand() with the current time
   srand((unsigned)time(NULL));      
       
   // Initialize seq to an ordered range 
   for ( i = 0; i < N; i++ )
   seq[i] = i;
         
   // Random shuffle 
   
   for ( i = 0; i < N - 1; i++ ) 
   {
    int r = ( rand() % ( N - i ) + 1 );
    int save = seq[i];
    seq[i] = seq[i + r];
    seq[i + r] = save;
   }
        
   printf ("\t*");
        
   // Test the sequence 
   for ( i = 0; i < 6; i++ )
   printf ( "%10d", seq[i] );
        
   printf ("\t*");
   printf("\n");
        
   printf ("\t*                                                               *\n");
   printf ("\t*                                                               *\n");
   printf ("\t* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
 for ( y = 0; y < players; y++) 
   {  
       printf("\n Payer ");  
         printf("%d",y+1); 
     
       
   for ( x = 0; x < bet; x++) 
   {   
       for (j = 0; j < 6; j++) 
       {
           for (i = 0; i < 6; i++) 
           {
                if (seq[i] == tickets[x][j]) 
               {
                  ++matches;
               }
            }
        }
        
        if (matches ==6)      // In case all the 6 numbers are correct
        {   
            printf("\n\n\t  Ticket ");
            printf("%i",x+1);
            printf("\n\n\t  --------");
            printf("\n\n\t  Congratulations!");
            printf("\n\n\t  Congratulations!");
            printf(" You won the jackpot!!");
            printf("\n\n\t  You won the Rs 100,000 !!");
            total=total+100000;           
        } 
       
       else if (matches ==5)      // In case there are 5 correct numbers
        {   
            printf("\n\n\t  Ticket ");
            printf("%i",x+1);
            printf("\n\n\t  --------");
            printf("\n\n\t  Congratulations!");
            printf(" You got %i",matches);
            printf(" correct numbers");
            printf("\n\n\t  You won Rs 10,000 !!");
            total=total+ 10000;   
        } 
       
       else if (matches ==4)      // In case there are 4 correct numbers
        {   
            printf("\n\n\t  Ticket ");
            printf("%i",x+1);
            printf("\n\n\t  --------");
            printf("\n\n\t  Congratulations!");
            printf(" You got %i",matches);
            printf(" correct numbers");
            printf("\n\n\t  You won Rs 5,000 !!");
            total=total+ 5000;   
        } 
       
       else if (matches ==3)      // In case there are 3 correct numbers
        {   
            printf("\n\n\t  Ticket ");
            printf("%i",x+1);
            printf("\n\n\t  --------");
            printf("\n\n\t  Congratulations!");
            printf(" You got %i",matches);
            printf(" correct numbers");
            printf("\n\n\t  You won Rs 1,000 !!");
            total=total+ 1000;       
        } 
        
       else if (matches ==2)      // In case there are 2 correct numbers
        {   
            printf("\n\n\t  Ticket ");
            printf("%i",x+1);
            printf("\n\n\t  --------");
            printf("\n\n\t  Congratulations!");
            printf(" You got %i",matches);
            printf(" correct numbers");
            printf("\n\n\t  You won Rs 500 !!"); 
            total=total+ 500;   
        } 
       
       else if (matches ==1)      // In case there is 1 correct number
        {   
            printf("\n\n\t  Ticket ");
            printf("%i",x+1);
            printf("\n\n\t  --------");
            printf("\n\n\t  Congratulations!");
            printf(" You got %i",matches);
            printf(" correct numbers");
            printf("\n\n\t  You won Rs 100 !!");
            total=total+ 100;            
        } 
          
       else if (matches ==0)     // In case there is no correct number 
        {
            printf("\n\n\t  Ticket ");
            printf("%i",x+1);
            printf("\n\n\t  --------");
            printf("\n\n\t  Sorry no correct numbers, try your luck again!");  
        }   
         
        matches=0;           // Reseting the variable matches to 0             
  
}
         printf ("\n\n");
         printf ("\t* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
         printf ("\t*                                                               *\n");
         printf ("\t*                                                               *\n");
         
         total=total+ money;  
         play = bet*20;
         printf("\t*  You played for Rs ");  
         printf("%d",play); 
         printf(" and won Rs ");   
         printf(" %d",total);
         printf("\t\t\t\t*\n");
         printf ("\t*                                                               *\n");
         printf ("\t*                                                               *\n");
         printf ("\t* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
         total = 0;
}
  check();                 // Calling the input function
  free(tickets);           // Releasing the memory    
   
}

I tried to put the loop, but its not working coz of the 2-D array i think..

My suggestion would be to read the errors and warnings that are most certainly being thrown.

In function `single':
258 `tickets' undeclared (first use in this function)
(Each undeclared identifier is reported only once
for each function it appears in.)

This error was produced..

Where do you declare tickets and where do you use it? Consider the following reproduction of your error:

{
    int tickets;
}

tickets = 0; // Error: 'tickets' undeclared

Where do you declare tickets and where do you use it? Consider the following reproduction of your error:

{
    int tickets;
}

tickets = 0; // Error: 'tickets' undeclared

this line int (*tickets)[6] = malloc(players * sizeof *tickets);, the problem is that its being declared in a function but if i put it in a nested loop it will end when the loop end..
and its if is need below after the loop, it wont be recognise.. is there a way to as if declare it as a global variable ?

ahhh these code are making sick...

@narue can u find a solution to the following plss :$

// Defining the single function
    int single()
    {
    system ("cls"); // Clear the screen
     
    display(); // Calling the display function
     
    printf("\n How much you tickets you want to bet (Rs20 per ticket): ");
    scanf("%i",&bet);
     
    int (*tickets)[6] = malloc(bet * sizeof *tickets);
     
    for ( x = 0; x < bet; x++)
    {
    printf("\n Enter the 6 numbers ( 1 - 40): : ");
    fflush(stdout);
     
    for ( i = 0; i < 6; i++)
    scanf("%d", &tickets[x][i]);
    }
     
    system ("cls"); // Clear the screen
     
    printf ("\n");
    printf ("\t* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
    printf ("\t* *\n");
    printf ("\t* The 6 series numbers you selected: *\n");
    printf ("\t* ---------------------------------- *\n");
    printf ("\t* *\n");
     
     
    for ( x = 0; x < bet; x++)
    {
    printf ("\t*");
    for( i=0;i<6;i++)
    printf ("%10d",tickets[x][i]); // Printing the values from the array num
    printf ("\t*\n");
    printf ("\t* *\n");
    }
     
    printf ("\t* *\n");
    printf ("\t* *\n");
    printf ("\t* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
     
    printf ("\n");
    printf ("\t* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
    printf ("\t* *\n");
    printf ("\t* The Winning outcomes are: *\n");
    printf ("\t* ------------------------- *\n");
    printf ("\t* *\n");
     
    // Seeding rand() with the current time
    srand((unsigned)time(NULL));
     
    // Initialize seq to an ordered range
    for ( i = 0; i < N; i++ )
    seq[i] = i;
     
    // Random shuffle
    for ( i = 0; i < N - 1; i++ )
    {
    int r = ( rand() % ( N - i ) + 1 );
    int save = seq[i];
    seq[i] = seq[i + r];
    seq[i + r] = save;
    }
     
    printf ("\t*");
     
    // Test the sequence
    for ( i = 0; i < 6; i++ )
    printf ( "%10d", seq[i] );
     
    printf ("\t*");
    printf("\n");
     
    printf ("\t* *\n");
    printf ("\t* *\n");
    printf ("\t* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
     
    // For comparison, Nested loops were used since the arrays are small
    for ( x = 0; x < bet; x++)
    {
    for (j = 0; j < 6; j++)
    {
    for (i = 0; i < 6; i++)
    {
    if (seq[i] == tickets[x][j])
    {
    ++matches;
    }
    }
    }
     
    if (matches ==6) // In case all the 6 numbers are correct
    {
    printf("\n\n\t Ticket ");
    printf("%i",x+1);
    printf("\n\n\t --------");
    printf("\n\n\t Congratulations!");
    printf("\n\n\t Congratulations!");
    printf(" You won the jackpot!!");
    printf("\n\n\t You won the Rs 100,000 !!");
    total=total+100000;
    }
     
    else if (matches ==5) // In case there are 5 correct numbers
    {
    printf("\n\n\t Ticket ");
    printf("%i",x+1);
    printf("\n\n\t --------");
    printf("\n\n\t Congratulations!");
    printf(" You got %i",matches);
    printf(" correct numbers");
    printf("\n\n\t You won Rs 10,000 !!");
    total=total+ 10000;
    }
     
    else if (matches ==4) // In case there are 4 correct numbers
    {
    printf("\n\n\t Ticket ");
    printf("%i",x+1);
    printf("\n\n\t --------");
    printf("\n\n\t Congratulations!");
    printf(" You got %i",matches);
    printf(" correct numbers");
    printf("\n\n\t You won Rs 5,000 !!");
    total=total+ 5000;
    }
     
    else if (matches ==3) // In case there are 3 correct numbers
    {
    printf("\n\n\t Ticket ");
    printf("%i",x+1);
    printf("\n\n\t --------");
    printf("\n\n\t Congratulations!");
    printf(" You got %i",matches);
    printf(" correct numbers");
    printf("\n\n\t You won Rs 1,000 !!");
    total=total+ 1000;
    }
     
    else if (matches ==2) // In case there are 2 correct numbers
    {
    printf("\n\n\t Ticket ");
    printf("%i",x+1);
    printf("\n\n\t --------");
    printf("\n\n\t Congratulations!");
    printf(" You got %i",matches);
    printf(" correct numbers");
    printf("\n\n\t You won Rs 500 !!");
    total=total+ 500;
    }
     
    else if (matches ==1) // In case there is 1 correct number
    {
    printf("\n\n\t Ticket ");
    printf("%i",x+1);
    printf("\n\n\t --------");
    printf("\n\n\t Congratulations!");
    printf(" You got %i",matches);
    printf(" correct numbers");
    printf("\n\n\t You won Rs 100 !!");
    total=total+ 100;
    }
     
    else if (matches ==0) // In case there is no correct number
    {
    printf("\n\n\t Ticket ");
    printf("%i",x+1);
    printf("\n\n\t --------");
    printf("\n\n\t Sorry no correct numbers, try your luck again!");
    }
     
    matches=0; // Reseting the variable matches to 0
    }
    printf ("\n\n");
    printf ("\t* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
    printf ("\t* *\n");
    printf ("\t* *\n");
     
    total=total+ money;
    play = bet*20;
    printf("\t* You played for Rs ");
    printf("%d",play);
    printf(" and won Rs ");
    printf(" %d",total);
    printf("\t\t\t\t*\n");
    printf ("\t* *\n");
    printf ("\t* *\n");
    printf ("\t* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
     
    check(); // Calling the input function
    free(tickets); // Releasing the memory
    }


The problem is that in the multi player mode, the program will ask the user how many players there are, then it will the loop the single player mode function for the "number of players" times..

I tried to put the loop, but its not working coz of the 2-D array i think.. can u chek it plss..

C Syntax (Toggle Plain Text)

    int multi()
    {
    system ("cls"); // Clear the screen
     
    display(); // Calling the display function
     
    printf("\n Number of players to play the game: ");
    scanf("%i",&players);
     
    printf("\n How much you tickets you want to bet(Rs20 per ticket): ");
    scanf("%i",&bet);
     
     
     
    for ( y = 0; y < players; y++)
    {
    int (*tickets)[6] = malloc(bet * sizeof *tickets);
    printf("\n For Payer ");
    printf("%d",y+1);
    printf(": \n");
    for ( x = 0; x < bet; x++)
    {
     
     
     
    printf("Enter the 6 numbers ( 1 - 40): : ");
    fflush(stdout);
     
    for ( i = 0; i < 6; i++)
    scanf("%d", &tickets[x][i]);
    }
    }
    system ("cls"); // Clear the screen
     
    printf ("\n");
    printf ("\t* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
    printf ("\t* *\n");
    printf ("\t* The 6 series numbers you selected: *\n");
    printf ("\t* ---------------------------------- *\n");
    printf ("\t* *\n");
     
    for ( y = 0; y < players; y++)
    {
    for ( x = 0; x < bet; x++)
    {
    printf("\n For Payer ");
    printf("%d",y+1);
     
    printf ("\n\t*");
    for( i=0;i<6;i++)
     
    printf ("%10d",tickets[x][i]); // Printing the values from the array num
    printf ("\t*\n");
    printf ("\t* *\n");
    }
    }
    printf ("\t* *\n");
    printf ("\t* *\n");
    printf ("\t* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
     
     
    printf ("\n");
    printf ("\t* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
    printf ("\t* *\n");
    printf ("\t* The Winning outcomes are: *\n");
    printf ("\t* ------------------------- *\n");
    printf ("\t* *\n");
     
    // Seeding rand() with the current time
    srand((unsigned)time(NULL));
     
    // Initialize seq to an ordered range
    for ( i = 0; i < N; i++ )
    seq[i] = i;
     
    // Random shuffle
     
    for ( i = 0; i < N - 1; i++ )
    {
    int r = ( rand() % ( N - i ) + 1 );
    int save = seq[i];
    seq[i] = seq[i + r];
    seq[i + r] = save;
    }
     
    printf ("\t*");
     
    // Test the sequence
    for ( i = 0; i < 6; i++ )
    printf ( "%10d", seq[i] );
     
    printf ("\t*");
    printf("\n");
     
    printf ("\t* *\n");
    printf ("\t* *\n");
    printf ("\t* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
    for ( y = 0; y < players; y++)
    {
    printf("\n Payer ");
    printf("%d",y+1);
     
     
    for ( x = 0; x < bet; x++)
    {
    for (j = 0; j < 6; j++)
    {
    for (i = 0; i < 6; i++)
    {
    if (seq[i] == tickets[x][j])
    {
    ++matches;
    }
    }
    }
     
    if (matches ==6) // In case all the 6 numbers are correct
    {
    printf("\n\n\t Ticket ");
    printf("%i",x+1);
    printf("\n\n\t --------");
    printf("\n\n\t Congratulations!");
    printf("\n\n\t Congratulations!");
    printf(" You won the jackpot!!");
    printf("\n\n\t You won the Rs 100,000 !!");
    total=total+100000;
    }
     
    else if (matches ==5) // In case there are 5 correct numbers
    {
    printf("\n\n\t Ticket ");
    printf("%i",x+1);
    printf("\n\n\t --------");
    printf("\n\n\t Congratulations!");
    printf(" You got %i",matches);
    printf(" correct numbers");
    printf("\n\n\t You won Rs 10,000 !!");
    total=total+ 10000;
    }
     
    else if (matches ==4) // In case there are 4 correct numbers
    {
    printf("\n\n\t Ticket ");
    printf("%i",x+1);
    printf("\n\n\t --------");
    printf("\n\n\t Congratulations!");
    printf(" You got %i",matches);
    printf(" correct numbers");
    printf("\n\n\t You won Rs 5,000 !!");
    total=total+ 5000;
    }
     
    else if (matches ==3) // In case there are 3 correct numbers
    {
    printf("\n\n\t Ticket ");
    printf("%i",x+1);
    printf("\n\n\t --------");
    printf("\n\n\t Congratulations!");
    printf(" You got %i",matches);
    printf(" correct numbers");
    printf("\n\n\t You won Rs 1,000 !!");
    total=total+ 1000;
    }
     
    else if (matches ==2) // In case there are 2 correct numbers
    {
    printf("\n\n\t Ticket ");
    printf("%i",x+1);
    printf("\n\n\t --------");
    printf("\n\n\t Congratulations!");
    printf(" You got %i",matches);
    printf(" correct numbers");
    printf("\n\n\t You won Rs 500 !!");
    total=total+ 500;
    }
     
    else if (matches ==1) // In case there is 1 correct number
    {
    printf("\n\n\t Ticket ");
    printf("%i",x+1);
    printf("\n\n\t --------");
    printf("\n\n\t Congratulations!");
    printf(" You got %i",matches);
    printf(" correct numbers");
    printf("\n\n\t You won Rs 100 !!");
    total=total+ 100;
    }
     
    else if (matches ==0) // In case there is no correct number
    {
    printf("\n\n\t Ticket ");
    printf("%i",x+1);
    printf("\n\n\t --------");
    printf("\n\n\t Sorry no correct numbers, try your luck again!");
    }
     
    matches=0; // Reseting the variable matches to 0
     
    }
    printf ("\n\n");
    printf ("\t* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
    printf ("\t* *\n");
    printf ("\t* *\n");
     
    total=total+ money;
    play = bet*20;
    printf("\t* You played for Rs ");
    printf("%d",play);
    printf(" and won Rs ");
    printf(" %d",total);
    printf("\t\t\t\t*\n");
    printf ("\t* *\n");
    printf ("\t* *\n");
    printf ("\t* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
    total = 0;
    }
    check(); // Calling the input function
    free(tickets); // Releasing the memory
     
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.