60 370
Assignments Done
98,1%
Successfully Done
In April 2018

Answer to Question #26941 in C# for miths

Question #26941
Write a program to identify whether the number entered bya user is even or odd??
Expert's answer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EvenOdd
{
class Program
{
static void Main(string[] args)
{
int number;//input number
Console.Write("Enter number: ");//enter number
number = int.Parse(Console.ReadLine());//read number
if (IsOdd(number)) {//check if number is odd
Console.WriteLine("Enter number is Odd. ");
}
if (IsEven(number))//check is number is even
{
Console.WriteLine("Enter number is Even.");
}
Console.WriteLine("Press any key to exit....");
Console.ReadLine();
}
// function check odd number
static bool IsOdd(int value)
{
return value % 2 != 0;
}
// function check even number
static bool IsEven(int value)
{
return value % 2 == 0;
}
}
}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions