Sunday, March 2, 2014

Conditional OperatorsEx01: (Wk-3), Jan 22, 2014

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Conditional_Operators
{
    class Program
    {
        static void Main(string[] args)
        {
            startover:
            Console.Write("Enter an x value: ");
            int x = Convert.ToInt32(Console.ReadLine());

            Console.Write("Enter a y value: ");
            int y = Convert.ToInt32(Console.ReadLine());

            if (x > 5 && y < 10) //both have to be true to run the "if" code
            {
                Console.WriteLine("\nX is indeed greater than 5 " + " and y is indeed less than 10");
            }
            else //if either one is false, it runs the else code
            {
                Console.WriteLine("\nEither x is not greater than 5 " + "or y is not less than 10");
            }
            Console.WriteLine("\n\nHit a key to continue");
            Console.ReadLine();
            Console.Clear();
            goto startover;
        }
    }
}

No comments:

Post a Comment