Generally everyone have different approach. I would recommend you to have different functions for everything.
I'm not sure with what you need help with. Is it the logic u are having problem with or the language?
I will just write the algorithm for you
Before Calculate total is called, we need to determine whether the player lose or not.
So lets make a new function
function void tosscoin (int playerwin, int playerlose)
rand(1) << generate random number from 0 - 1. I am not sure how you call it in c++ just reffer to the documentation
if rand == 0
pmoney = pmoney + 2 //If the player lose then add 2 dollars to the player's money
playerwin = playerwin + 1 //Playerwin is a global variable(int)
pmoney = pmoney -1 //If the player lose then deduct 1 dollar from the money
playerlose = playerlose + 1 //Playerlose is a global variable(int)
game = game + 1 //Game is a global variable. Place it before the main function
If game == 20 // if game has reached round 20 then call Calculate Total that display the total win and lose
Function void Calculatetotal(int playerwin, int playerlose)