SOURCE
CODE :-
using System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace sumodd
{
class sum
{
public void sumodd()
{
int
i;
int
sam = 0;
for (i
= 0; i <= 100; i++)
{
if (i%2 != 0)
{
int
count = 0;
sam = sam + i;
count++;
}
}
Console.WriteLine("sum of 1+3+5+...100 is " + sam);
}
}
class Program
{
static void Main(string[]
args)
{
sum
s = new sum();
s.sumodd();
}
}
}
OUTPUT:-
SUM OF 1+3+5+… 100 IS 2500
No comments:
Write comments