Advertisement
svephoto

Even Number [C#]

Apr 29th, 2021
1,524
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.55 KB | None | 0 0
  1. using System;
  2.  
  3. namespace EvenNumber
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int input = int.Parse(Console.ReadLine());
  10.  
  11.             while (input % 2 != 0)
  12.             {
  13.                 Console.WriteLine("Please write an even number.");
  14.  
  15.                 input = int.Parse(Console.ReadLine());
  16.  
  17.                 if (input % 2 == 0)
  18.                 {
  19.                     break;
  20.                 }
  21.             }
  22.  
  23.             Console.WriteLine($"The number is: {Math.Abs(input)}");
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement