using System;
using System.Collections.Generic;using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace sum_odd
{
Class Program
{
static void main(string[] args)
{
int i, sum = 0;
Console.WriteLine("The first five odd numbers are:");
for(i=1; i<10; i++)
{
{
if (i%2 != 0)
{
Console.WriteLine("{0}",i);
sum = sum +i;
}
}
Console.WriteLine("The sum of the first five odd number is :{0}",sum);
Console.ReadLine();
}
}
}
OUPUT:
The first five odd numbers are:
1
3
5
7
9
The sum of the first five odd number is : 25
Comments
Post a Comment