using System;
using System.Collections.Generic;using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace sum_even
{
Class Program
{
static void main(string[] args)
{
int i, sum=0;
Console.WriteLine("The first five even numbers are: ");
for(i=0; i<12; i++)
{
if (i%2 == 0)
{
Console.WriteLine("{0}",i);
sum = sum +i;
}
}
Console.WriteLine("The sum of the first five even numbers is :{0}",sum);
Console.ReadLine();
}
}
}
OUTLINE:
The first five even numbers are:
2
4
6
8
10
The sum of the first five even numbers is 30
Comments
Post a Comment