Guest User

04.CheckIfDigitIsSeven

a guest
Nov 3rd, 2012
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.32 KB | None | 0 0
  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 = int.Parse(Console.ReadLine()) / 100; //if the number is 1732, number equals 17
  9.         Console.WriteLine(number%10 == 7);
  10.     }
  11. }
Advertisement
Add Comment
Please, Sign In to add comment