Comparing Marks of Three Subjects Using If-Else Statement in c#

 Comparing Marks of Three Subjects

output:


CODE:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;


namespace if_else_condition

{

    class Program

    {

        static void Main(string[] args)

        {

            int m, p, c;

            Console.WriteLine("Enter marks of Math:");

            m = int.Parse(Console.ReadLine());

            Console.WriteLine("Enter marks of Physics:");

            p = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Enter marks of Chemistry:");

            c = Convert.ToInt32(Console.ReadLine());

            if (m > p)

            {

                if (m > c)

                {

                    Console.WriteLine("Mark of Maths is Highest:{0}", m);

                }

                else { Console.WriteLine("Mark of Chemistry is Highest:{0}", c); }

            }


            else if (c > p)

            {

                Console.WriteLine("Mark of Chemistry is Highest:{0}", c);

            }

            else

            {

                Console.WriteLine("Mark of Physics is Highest:{0}", p);

            }

        }



    }

}






Comments

Popular posts from this blog

Vertical and Reverse Paramid in c# using loop.

Calculator in c# using Static Methods

Calculator in c# using Method void method