Task: Pig the dice game
C: #include <stdio.h>
#include <stdlib.h>
#include <time.h>


const int NUM_PLAYERS = 2;
const int MAX_POINTS = 100;



int randrange(int min, int max){
    return (rand() % (max - min + 1)) + min;
}



void ResetScores(int *scores){
    for(int i = 0; i < NUM_PLAYERS; i++){
        scores[i] = 0;
    }
}


void Play(int *scores){
    int scoredPoints = 0;
    int diceResult;
    int choice;

    for(int i = 0; i < NUM_PLAYERS; i++){
        while(1){
            printf("Player %d - You have %d total points and %d points this turn \nWhat do you want to do (1)roll or (2)hold: ", i + 1, scores[i], scoredPoints);
            scanf("%d", &choice);

            if(choice == 1){
                diceResult = randrange(1, 6);
                printf("\nYou rolled a %d\n", diceResult);

                if(diceResult != 1){
                    scoredPoints += diceResult;
                }
                else{
                    printf("You loose all your points from this turn\n\n");
                    scoredPoints = 0;
                    break;
                }
            }
            else if(choice == 2){
                scores[i] += scoredPoints;
                printf("\nYou holded, you have %d points\n\n", scores[i]);

                break;
            }
        }

        scoredPoints = 0;
        CheckForWin(scores[i], i + 1);

    }
}


void CheckForWin(int playerScore, int playerNum){
    if(playerScore >= MAX_POINTS){
        printf("\n\nCONGRATULATIONS PLAYER %d, YOU WIN\n\n!", playerNum);

        exit(EXIT_SUCCESS);
    }
}


int main()
{
    srand(time(0));

    int scores[NUM_PLAYERS];
    ResetScores(scores);

    while(1){
        Play(scores);
    }

    return 0;
}

VB: Option Explicit

Sub Main_Pig()
Dim Scs() As Byte, Ask As Integer, Np As Boolean, Go As Boolean
Dim Cp As Byte, Rd As Byte, NbP As Byte, ScBT As Byte
    
    Const INPTXT As String = "Enter number of players : "
    Const INPTITL As String = "Numeric only"
    Const ROL As String = "Player ¤¤¤¤ rolls the die."
    Const MSG As String = "Do you want to ""hold"" : "
    Const TITL As String = "Total if you keep : "
    Const RES As String = "The die give you : ¤¤¤¤ points."
    Const ONE As String = "The die give you : 1 point. Sorry!" & vbCrLf & "Next player."
    Const WIN As String = "Player ¤¤¤¤ win the Pig Dice Game!"
    Const STW As Byte = 100

    Randomize Timer
    NbP = Application.InputBox(INPTXT, INPTITL, 2, Type:=1)
    ReDim Scs(1 To NbP)
    Cp = 1
    Do
        ScBT = 0
        Do
            MsgBox Replace(ROL, "¤¤¤¤", Cp)
            Rd = Int((Rnd * 6) + 1)
            If Rd > 1 Then
                MsgBox Replace(RES, "¤¤¤¤", Rd)
                ScBT = ScBT + Rd
                If Scs(Cp) + ScBT >= STW Then
                    Go = True
                    Exit Do
                End If
                Ask = MsgBox(MSG & ScBT, vbYesNo, TITL & Scs(Cp) + ScBT)
                If Ask = vbYes Then
                    Scs(Cp) = Scs(Cp) + ScBT
                    Np = True
                End If
            Else
                MsgBox ONE
                Np = True
            End If
        Loop Until Np
        If Not Go Then
            Np = False
            Cp = Cp + 1
            If Cp > NbP Then Cp = 1
        End If
    Loop Until Go
    MsgBox Replace(WIN, "¤¤¤¤", Cp)
End Sub