In this simple C# tutorial we check whether number entered by the user is even or odd. Here we take "float" datatype, you can also take "int" or "double" datatype too depending on the number entered by the user and variable "num" for the number entered by the user. To check whether the no is even or odd we were taking "if-else" condition statement.
using System; class check { public static void Main(String []args) { float num; Console.WriteLine("Enter number:"); num=Convert.ToInt32(Console.ReadLine()); if(num%2==0) { Console.WriteLine("\nnum is even "); } else { Console.WriteLine("\nnum is "); } } }
0 comments:
Post a Comment