CSharp - Write program to throw a coin once and check if it is Head or Tail


You will write a program that throws a coin once.

Output if it is head or tail.


Generate a random number-zero or one-and convert it to heads or tails subsequently.

Next method requires the upper bound of a random number range to be augmented by 1.


using System;
class Program//from  ww w .  j a v  a 2s.  c om
    static void Main(string[] args)
        // Random number generator 
        Random randomNumbers = new Random();

        // Random number 0/1 and its transformation 
        int randomNumber = randomNumbers.Next(0, 1 + 1);
        if (randomNumber == 0)
            Console.WriteLine("Head tossed");
            Console.WriteLine("Tail tossed");