Pages

Write a program that find even and odd number

INPUT:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Even_Odd
{
    class Program
    {
        static void Main(string[] args)
        {
            int odd_num, even_num,num1,num2,numa,numb;
            Console.WriteLine("Enter num1");
            num1 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter num2");
            num2 = Convert.ToInt32(Console.ReadLine());
            numa = num1 % 2;
            numb = num2 % 2;

            if (numa == 0)
            {
                Console.WriteLine("num1 is even", num1);
            }
            if (numb == 0)
            {
                Console.WriteLine("num2 is even", num2);   
            }
           
                if (numa == 1)
                {
                    Console.WriteLine("num1 is odd", num1);
                }
            if (numb == 1)
            {
                Console.WriteLine("num2 is odd", num2);
            }
        }

OUTPUT:


No comments:

Post a Comment