Thread: Flipping a coin!

  1. #1
    Registered User
    Join Date
    Mar 2012

    Flipping a coin!


    Just a beginner! I've got a darts game between two players. I need to work out how many games player 1 wins and player 2 wins out of 1000 games if there is a coin flip and thereafter the loser starts.

    if (p1 < p2) 
            wins = 1 ;
            wins = 0 ;

    This is my code for if p1 has less throws than p2 then they win. I just don't know how to make them flip for it!

    Thanks alot,

    Last edited by Valdo; 03-25-2012 at 09:13 AM.

  2. #2
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Liverpool UK
    well its just a 0 / 1 random number genertion isnt it
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  3. #3
    Join Date
    Oct 2007
    Inside my computer
    You can find out about random numbers by studying std::rand and std::srand.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. coin toss
    By ejd81882 in forum C Programming
    Replies: 3
    Last Post: 10-14-2008, 12:53 PM
  2. coin flipping
    By MiroMage in forum C Programming
    Replies: 5
    Last Post: 10-01-2008, 06:47 PM
  3. coin problem
    By et1wilson in forum C Programming
    Replies: 5
    Last Post: 07-14-2008, 05:19 AM
  4. Problems with a simple coin flipping program
    By Thileepan_Bala in forum C Programming
    Replies: 14
    Last Post: 01-18-2008, 08:33 PM
  5. Coin Toss
    By kazuakijp in forum C Programming
    Replies: 4
    Last Post: 08-31-2004, 09:02 PM