Wednesday 24 April 2013

Write a program to accept two numbers and display the quotient as a result. In addition, an error message should be displayed if the second number is zero or greater than the first number. (Duration: 20 min)


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

namespace two_number_1
{
    class Program
    {
        static void Main(string[] args)
        {
            int num1, num2, result;
            Console.WriteLine("Enter two numbers");
            num1 = Convert.ToInt32(Console.ReadLine());
            num2 = Convert.ToInt32(Console.ReadLine());
            if (num2 != 0)
            {
                if (num2 < num1)
                {
                    result = num2 / num2;
                    Console.WriteLine("result");
                }
                else
                {
                    Console.WriteLine("A number cannot be divided by a number greater than itself");
                }
            }
            else
            {
                Console.WriteLine("A number cannot be divided by zero");
            }
        }

    }
}

No comments:

Post a Comment