stkirov

04.CheckIfThirdNumberIsSeven

Nov 3rd, 2012
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Write an expression that checks for given integer if its third digit (right-to-left) is 7. E. g. 1732  true.
  2. using System;
  3.  
  4. class Program
  5. {
  6.     static void Main()
  7.     {
  8.         int number = Math.Abs(int.Parse(Console.ReadLine())) / 100; //if the number is 1732, number equals 17; we make the number with an absolute value in order t work for negative numbers
  9.         Console.WriteLine(number%10 == 7);
  10.     }
  11. }
Advertisement
Add Comment
Please, Sign In to add comment