9 October 2013

C# program to sum up odd numbers from 0 to 50



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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int sum = 0, i;
            Console.Write("Sum of Odd numbers between 0 and 50");
            for (i = 1; i <= 50; i = i + 2)
            {
                sum += i;
            }
            Console.Write("\nSum=" + sum);
            Console.ReadLine();
        }
    }
}

No comments:

Post a Comment