Friday, 1 September 2017

c# programming tutorial to Find maximum out of 3 numbers

Find maximum out of 3 numbers

using System;
class Program
    {
        static void Main(string[] args)
        {
int a, b,c;
Console.WriteLine("Number 1:");
a = Convert.ToInt32(Console.ReadLine());            
Console.WriteLine("Number 2:");            
b = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Number 3:");
c = Convert.ToInt32(Console.ReadLine());  
            if (a > b && a > c)
            {
                Console.WriteLine("a is max");
            }
            else if (b > a && b > c)
            {
                Console.WriteLine("b is max");
            }
            else
            {
                Console.WriteLine("c is max");
            }
        }

    }  

Output


0 comments:

Post a Comment