Input:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int num1, num2, num, t_even=0, t_odd=0;
Console.WriteLine("enter
range of initial value");
num1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("enter
range of final value");
num2 = Convert.ToInt32(Console.ReadLine());
for (int i = num1; i
<= num2; i++)
{
num = i % 2;
if (num == 0)
{
Console.WriteLine("number is even = {0}", i);
t_even = i+ t_even;
}
else if
(num == 1)
{
Console.WriteLine("nubers are odd = {0}", i);
t_odd = t_odd+i;
}
}
{
Console.WriteLine("even numbers are\n{0}\nodd num are\n{1}",
t_even, t_odd);
}
}
}
}
No comments:
Post a Comment