May 1, 2020

Write a program to identify the largest of three numbers entered by a user.

Write a program to identify the largest of three numbers entered by a user. Create this program by using methods.





Write a program to identify the largest of three numbers entered by a user

Sample Solution

C# Sharp Code

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

namespace Enter_5_Number
{
    class Number
    {
        static int n1, n2, n3;

        public static void Greater()
        {
            if (n1 > n2 && n1 > n3)
            {

 Console.WriteLine("The Greatest Of Three numbers are:" + n1);
            }
            else if (n2 > n1 && n2 > n3)
            {
 Console.WriteLine("The Greatest Of Three numbers are:" + n2);
            }
            else
            {
 Console.WriteLine("The Greatest Of Three numbers are:" + n3);
            }
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Enter Three no:");
            n1 = Convert.ToInt32(Console.ReadLine());
            n2 = Convert.ToInt32(Console.ReadLine());
            n3 = Convert.ToInt32(Console.ReadLine());
            Greater();
            Console.ReadLine();
        }

    }
}

                                                                Sample Output

Write a program to identify the largest of three numbers entered by a user.



No comments:

Post a Comment