pupesko

SoftUni - 5.5 Third Digit is 7?

Oct 10th, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.50 KB | None | 0 0
  1. //Write an expression that checks for given integer if its third digit from right-to-left is 7.
  2.  
  3. using System;
  4.  
  5. class ThirdDigit
  6. {
  7.     static void Main()
  8.     {
  9.         Console.Write("Enter number a = ");
  10.         string numberA = Console.ReadLine();
  11.         int a = int.Parse(numberA);
  12.         int b = a / 100;
  13.         int c = b % 10;
  14.  
  15.         if (c == 7)
  16.         {
  17.             Console.WriteLine("true");
  18.         }
  19.         else
  20.         {
  21.             Console.WriteLine("false");
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment