using System; class TossACoin { public static void Main() { int face; //Head: face==1. Tail: face==0 int num_tosses = 0; Random random = new Random(); //A generator to create random numbers do { int random_int = random.Next(); //Generate a random integer face = random_int % 2; num_tosses++; } while (face == 0); //continue to toss if a tail is obtained Console.WriteLine("Tossed {0} times when a head is obtained", num_tosses); } }