Wednesday, 24 April 2013

Write a program to identify the largest of three numbers entered by a user. Create this program by using methods. (Duration: 25 min)


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

namespace ConsoleApplication72
{
   public class Program
    {
       static int number1, number2, number3;
       public static void Greater()
       {
           if (number1 > number2 && number1 > number3)
           {
               Console.WriteLine("first number is the greatest:{0}", number2);
           }
           else if (number2 > number1 && number2 > number3)
           {
               Console.WriteLine("second number is the greatest:{0}", number2);
           }
           else
           {
               Console.WriteLine("this number is the greatest:{0}", number3);
           }
       }
        static void Main(string[] args)
        {
            Console.WriteLine("enter the first number");
            number1 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("enter the second number");
            number2 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("enter the third number");
            number3 = Convert.ToInt32(Console.ReadLine());
            Console.ReadLine();
        }
    }
}

No comments:

Post a Comment