Pages

Using C# Console Program find the greater value from two Value using if/else Statment......


INPUT:

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

namespace a_is_g_b_statment_conditional
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            Console.WriteLine("Please enter the value of a");
            a = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Please enter the value of b");
            b = Convert.ToInt32(Console.ReadLine());
            Char op;
            Console.WriteLine("Please select operation \n for findind greatest value between two numbers press > \n for finding lowest value between two values press <");
            op= Convert.ToChar(Console.ReadLine());
            if(op=='>')

            if (a > b)
            {
                Console.WriteLine("{0} is greatest number among the values", a);
            }
            else
            {
                Console.WriteLine("{0} is the greatest number among tha values", b);
            }
            if(op=='<')
                if (a < b)
                {
                    Console.WriteLine("{0} is lowest value", a);
                }
                else
                {                                                

                    Console.WriteLine("{0} is lowest value", b);
                }
          }
     }
}

OUTPUT:

ALGORITHM:

  • ·         Start,
  • ·         Initializing: double a,b,greater num,less  num;
  • ·         Output: Please enter num a
  • ·         Set numa: Taking input from the user
  • ·         Output: Please enter num b
  • ·         Set numb: 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
  • ·         Output: Result
  • ·         Result= num A GREATEST or num b is greatest.
  • ·         End

No comments:

Post a Comment