Monday 28 January 2013


// Write a program to find out m / n without using the / operator
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace prog6
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = 0, m = 0, d = 0;
            Console.WriteLine("Enter M value");
            m = int.Parse(Console.ReadLine());
            Console.WriteLine("Enter Nvalue");
            n = int.Parse(Console.ReadLine());
            if (n == 1)
                Console.WriteLine("Result" + m);
            else
            {
                while (m > 1)
                {
                    m = m - n;
                    d++;
                }
                //Moving to the next line 
                Console.WriteLine();
                //Waiting for any keypress 
                Console.ReadKey();

            }
        }
    }
}

No comments:

Post a Comment