Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ThirdDigitIsSeven
- {
- class ThirdDigit7
- {
- static void Main()
- {
- while (true)
- {
- int number;
- bool thirdDigitIsSeven = false;
- Console.WriteLine("Enter a number to check if it's third digit from right to left is 7");
- bool valid = int.TryParse(Console.ReadLine(),out number);
- if (valid && number <= int.MaxValue)
- {
- thirdDigitIsSeven = ((number % 1000) / 100 == 7);
- Console.WriteLine(thirdDigitIsSeven);
- }
- else
- {
- Console.WriteLine("Invalid input!Try again:");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement