Dot Net Code: Write A Program To Find Minimum Among Three Numbers
by , 02-04-2012 at 05:45 AM (653 Views)
Code://CONTEXT:-TO FIND THE MINIMUM AMONG THREE NUMBERS //ASSUMPTION:-NONE; //CONTRACT:-"Min(int,int,int)->int" //EXAMPLE:-Min(3,2,1)->1,Min(87,6,76)->6 //SPECIAL CONSIDERATION:-NONE /*PSUEDO CODE:-"Min(a,b,c) * { int min = b > c ? c : b; int min1 = a > min ? min : a; return min1; }*/ /*TEST CASES:- INPUT EXPECTED ACTUAL STATUS * (2,3,4) 2 2 Satisfied * (1,6,8) 1 1 Satisfied */ using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace minimum { class Program { static int Min(int a, int b, int c) { int min = b >= c ? c : b; int min1 = a >= min ? min : a; return min1; } static void Main(string[] args) { Console.WriteLine("ENTER 3 NOS"); int x=int.Parse(Console.ReadLine()); int y=int.Parse(Console.ReadLine()); int z=int.Parse(Console.ReadLine()); int minimum = Min(x, y, z); Console.WriteLine("MINIMUM OF ALL IS=" + minimum); Console.Read(); } } }
Comments
Leave Comment








Email Blog Entry