Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Wednesday 22 March 2017

Simple program


Simple program #1 (Check whether a number is even or odd)

Number: 5, is Odd.
Number: 10, is Even.

The program is written in C# programming language and will accept a number as input. The logic of the program is to find whether the number is even or odd.
 
Simple program

Note: If you are new to C# and Console Application. Try to code First C# Program

Note: Read articles on how to use Loops and Conditions.

Let’s find out a simple and easy way to code the program.

Practical Implementation:

using System;

namespace patternProblem.Simple_program
{
    class Simple1   //Checking Even and Odd number
    {
        static void Main(string[] args)
        {
            Console.Write("Enter number: ");
            int n = Convert.ToInt32(Console.ReadLine());
           
            if (n % 2 == 0)
            {
                Console.WriteLine("Number: {0}, is Even.", n);
            }
            else
            {
                Console.WriteLine("Number: {0}, is Odd.", n);
            }

            Console.ReadKey();
        }
    }
}

Output:
The input number here is 5, which is odd. The output is shown below:

Enter number: 5
Number: 5, is Odd.
Press any key to continue . . .


For any query, comment us below.

Skip to Main Table Simple program

Next – Simple program #2

Click imagination hunt to read latest blogs.


Keep learning and sharing...

No comments:

Post a Comment

Featured post

Think that makes you rich and richer

 Napolean said: “You can think and grow rich, but if you can be brought up like most people with work and you won't starve, this wil...