C# Program to find smallest of the numbers entered by user

Sunday, 12 February 2012

Code:
using System;
class Smallest
{
    public static void Main()
    {
    int n1, n2, n3;
    Console.WriteLine("Enter Three no:");
    n1=Convert.ToInt32(Console.ReadLine());
    n2=Convert.ToInt32(Console.ReadLine());
    n3=Convert.ToInt32(Console.ReadLine());
    if(n1<n2)
        if(n1<n3)
        {
        Console.WriteLine("The Smallest Of Three numbers are:"+n1);
        }
        else
        {
        Console.WriteLine("The Smallest Of Three numbers are:"+n3);
        }
        else
        if(n2<n3)
        {
        Console.WriteLine( "The Smallest Of Three numbers are:"+n2);
        }
        else
        {
        Console.WriteLine("The Smallest Of Three numbers are:"+n3 );
        }
}
}
OUTPUT:-

0 comments:

Post a Comment