// 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 prog7 { class Program { static void Main(string[] args) { int n = 0, m = 0, def=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 " +def); else { while (m > 1) { m = m - n; //Once it meet such a condition that m become lesser then n that's mean now we can't devide m number through n if (m < n) break; } //Moving to the next line Console.WriteLine(); //Printing the biggest number from n number Console.WriteLine(" Result: " + m); } //Waiting for any keypress Console.ReadKey(); } } }
Monday, 28 January 2013
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment