Friday, 1 September 2017

C# programming tutorial to find the summation of all the odd and all the even numbers between two number

create a simple c# program to generate sum of odd and even number betwwen two number

Program

using System;
class Program
    {
        static void Main(string[] args)
        {
            int e = 0, o = 0, a = 200, b = 800;
            while (a <= b)
            {
                if (a % 2 == 0)
                {
                    e = e + a;
                }
                Else
                 {
                    o = o + a;
                }
                a++;
            }
            Console.WriteLine("Even Sum :{0}", e);
            Console.WriteLine("Odd Sum :{0}", o);
        }

     } 

Output


0 comments:

Post a Comment