Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- /*
- *Write an expression that checks for given integer if its third digit from right-to-left is 7
- */
- class ThirdDigitSeven
- {
- static void Main()
- {
- int numberOne = 1732;
- int numberTwo = 15691;
- bool thirdDigit;
- if (thirdDigit = (numberOne / 100) % 10 == 7)
- {
- Console.WriteLine("The third digit of {0} is 7", numberOne);
- }
- else
- {
- Console.WriteLine("The third digit is not 7");
- }
- if (thirdDigit = (numberTwo / 1000) % 10 == 7)
- {
- Console.WriteLine("The third digit of {0} is 7", numberTwo);
- }
- else
- {
- Console.WriteLine("The third digit of {0} is not 7", numberTwo);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement