So this program suppose to let user insert how many times they want to toss the coin and then the program will generate random numbers between 1 -2 , 1 for head, 2 for tails. and in the end display the total amount of heads and tails. But when I run this program that I wrote I always get all tails or all heads, for exanple if I input 5 to toss the coin 5 times its always either 5 tails or 5 heads, please help !
You are calling srand() every time you want a new random number. This sets the starting point in the random number sequence based on current time and this won't change sufficiently to give different numbers at successive calls.
Move the srand() call out of cointoss and put it at the start of main() so that it is called only once.
The single call to cointoss() outside the for loop (after your cin statement) is also redundant.
Please use code tags so that we can refer to line numbers and test your code. The formatting menu may not work on first post, but you can always put them in by hand or edit your post immediately after submission.