Search

An introduction to coding and programming - Decisions decisions

//#######                                        #####                              
//#       #    # #####  #      #  ####  # ##### #     #  ####  #####  ###### #####  
//#        #  #  #    # #      # #    # #   #   #       #    # #    # #      #    # 
//#####     ##   #    # #      # #      #   #   #       #    # #    # #####  #    # 
//#         ##   #####  #      # #      #   #   #       #    # #    # #      #####  
//#        #  #  #      #      # #    # #   #   #     # #    # #    # #      #   #  
//####### #    # #      ###### #  ####  #   #    #####   ####  #####  ###### #    # 

//***********************************************************************************************************************************
// Project      : Decisions decisions
// Solution     : Entry level coding
// Project type : Console application
// Platform     : Microsoft.NET 6.00
// Created with : Microsoft Visual Studio Community 2022 (64-bit) Version 17.0.6
// Created      : 03/10/2022
// Created By   : https://explicitcoder.com
//***********************************************************************************************************************************
// Instructions
// Select this project (Decisions decisions) from the dropdown box next to the green arrow
// at the top of Visual studio and then click the green play button to start it.
// To stop the program you can either click the close button on the console window or click the red stop button.
//***********************************************************************************************************************************
// Description
// C# can make decisions based on the value of something.
// The if statement can evaluate true and false so that the code can do different things depending on a value.
// The if statement can evaluate any logical condition that can be resolved to a true or false boolean value.
// The else statement will be executed when the if condition evaluates to false.
//***********************************************************************************************************************************

//***********************************************************************************************************************************
// SEE THE WEBSITE FOR MORE INFORMATION    https://explicitcoder.com/getting-started
//***********************************************************************************************************************************

namespace Decisions_decisions
{
    class Program
    {
        static void Main() // The program starts here. Main is the first method called when you run the program.
        {
            //An if statement evaluates a condition. If the condition is true the code inside will be executed. If it is not true the code will be skipped.

            // This condition will always be true.
            if (true) 
            {
                Console.WriteLine("This statement is true");
            }

            // This condition will evaluate to true because 15 is more than 10.
            if (15 > 10) 
            {
                Console.WriteLine("15 is more than 10");
            }

            // This condition will evaluate to true because 15 is less than 20.
            if (15 < 20) 
            {
                Console.WriteLine("15 is less than 20");
            }

            // This condition will evaluate to false because 6 is less than 7.
            if (6 > 7) 
            {
                // This code will be skipped because the condition is false.
                Console.WriteLine("6 is more than 7");
            }
            else
            {
                // This code will run because the condition is original false.
                Console.WriteLine("6 is not more than 7");
            }

            // Without this line the program will end before you have time to see it.
            Console.ReadLine();
        }
    }
}