Write a C# program to find even or odd number using function


Introduction

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 Functionexcercise
  4. {
  5. class Program
  6. {
  7.  
  8. static void Main(string[] args)
  9. {
  10. int number;
  11.  
  12. // Inputting number from user
  13. Console.WriteLine("Enter any number: ");
  14. number = Convert.ToInt32(Console.ReadLine());
  15.  
  16. CheckNumIsEvenOrOdd(number);
  17. Console.ReadLine();
  18.  
  19. }
  20.  
  21. public static void CheckNumIsEvenOrOdd(int _number)
  22. {
  23. if (_number % 2 == 0)
  24. {
  25. Console.WriteLine("Number {0} is Even", _number);
  26. }
  27. else
  28. {
  29. Console.WriteLine("Number {0} is Odd", _number);
  30. }
  31. }
  32.  
  33. }
  34.  
  35. }

Result

C# language techstudy

     





Related Topics




Popular Posts