Created
September 11, 2013 17:55
-
-
Save RMcGee/6527285 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Int32 number; | |
Console.WriteLine ("Enter 4 digit number"); | |
number = Int32.Parse(Console.ReadLine()); | |
Console.WriteLine("The first digit is {0}", number / 1000); | |
Console.ReadLine(); | |
Console.WriteLine ("The second digit is {0}", number % 1000 / 100); | |
Console.ReadLine(); | |
Console.WriteLine("The third digit is {0}", number % 100 / 10); | |
Console.ReadLine(); | |
Console.WriteLine("The fourth digit is {0}", number % 10 / 1); | |
Console.ReadLine(); | |
Console.WriteLine("The sum of the digits is {0}", (number / 1000) + (number % 1000 / 100) + (number % 100 / 10) + (number % 10 / 1)); | |
Console.ReadLine(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment