Write C# Program to check whether entered number is odd or even

Write C# Program to check whether entered number is odd or even


Introduction

Write C# Program to check whether entered number is odd or even. I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability..


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

  1. using System;
  2.  
  3. namespace csharpprograms
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int number;
  10. Console.WriteLine("Enter a number: ");
  11. number = Convert.ToInt32(Console.ReadLine());
  12.  
  13. // Even number if remainder is 0
  14. if (number % 2 == 0)
  15. Console.WriteLine("Entered Number is an Even Number");
  16. else
  17. Console.WriteLine("Entered Number is odd Number");
  18.  
  19. Console.ReadLine();
  20.  
  21. }
  22. }
  23. }
  24.  

Result

C# language techstudy.org

     





Related Topics




Popular Posts