Input:
using System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace A_B_C_2ND
{
class Program
{
static void
Main(string[] args)
{
double a, b, c;
Console.WriteLine("ENTER VALUE 1");
a = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("ENTER VALUE 2");
b = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("ENTER VALUE 3");
c = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("");
Console.WriteLine("select the operation");
Console.WriteLine("");
Char
op;
Console.WriteLine("For finding greatest value press 1");
Console.WriteLine("For finding lowest
value press 2");
op = Convert.ToChar(Console.ReadLine());
if (op == '1')
{
if
(a > b)
if
(a > c)
{
Console.WriteLine("{0} is
greatest number", a);
}
else
{
Console.WriteLine("{0} is
greatest number", c);
}
else
if
(b > c)
{
Console.WriteLine("{0} is greatest number", b);
}
else
{
Console.WriteLine("{0} is greatest number", c);
}
if
(a == b)
if(a==c)
if(b==c)
{
Console.WriteLine("{0}={1}={2} are equal", a, b, c);
}
}
else
{
if
(op == '2')
if
(a < b)
if (a < c)
{
Console.WriteLine("{0}
is lowest number", a);
}
else
{
Console.WriteLine("{0}
is lowest", c);
}
else
if (b < c)
{
Console.WriteLine("{0}
is lowest number", b);
}
else
{
Console.WriteLine("{0}
is lowest number", c);
}
if
(a == b)
if
(a == c)
if (b == c)
{
Console.WriteLine("{0}={1}={2} are equal", a, b, c);
}
}
}
}
}
OUTPUT:
ALGORITHM:
- · Start,
- · Initializing: double a,b,c,greater num,less num;
- · Output: Please enter num a
- · Set num a: Taking input from the user
- · Output: Please enter num b
- · Set num b: Taking input from the user
- · Output: Please enter num c
- · Set num c: Taking input from the user
- · Set data: by selection of any one operation.
- · Use th statement of if and else.
- · output:User have to select the operation by presing key.
- · Input: press 1 or 2 or 3
- · Output: Result
- · Result= num A GREATEST or num b is greatest or num c is greatest.
- · Result= num A least or num b is least or num c is least.
- · End
No comments:
Post a Comment