Building A Simple Program with C (DiceGame)

 DiceGame by Ashur Baroutta

    Recently I've been learning the basic's of a language new to me, called C. It is actually quite old though the way in which you code with it looks similar to Java. I was tasked with creating a dice game that featured two players rolling until one of them had accumulated 100 or more points. 

The rules for the game are simple, a player rolls 2 dice, if one of the dice is a 1 then the player records a 0 for the round. A player can choose to stand on their points accumulated that round to avoid the risk of rolling a 1 and scoring 0 for the turn. The first to reach a hundred or more wins. There are modifiers for specific scenarios, if a player should roll snake eyes (1 and 1) they score 25 points for that roll and if a player should roll two of the same number, that sum is doubled. 

    In theory, this game shouldn't have been so difficult to code though the way C works isn't the same as modern languages as it uses pointers to update values at the address of a variable in memory. This type of work is automagically completed in most languages I've encountered, so it caused a bit of confusion. The following is a snapshot of the most relevant parts of my code with another picture of its output. 






Comments

Post a Comment

Popular posts from this blog

IP #6 : Reversing an Integer

IP#5 : LinkedList Removing Duplicates II