Monday, September 10, 2012

How to find the largest of 3 numbers


using System;

namespace SimpleCodingQuestions
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(FindLargestNumber(6, 3, 9));
        }

        /// 
        /// Find the largest of three numbers
        /// 
/// first parameter /// second parameter /// third parameter /// public static long FindLargestNumber(long a, long b, long c) { // assume that the first value is the biggest long biggest = a; // check if b is the biggest if (b > biggest) biggest = b; // check if c is the biggest if (c > biggest) biggest = c; return biggest; } }
}

No comments:

Post a Comment