Q:-Write a program that print even numbers from 1 to 20?????
Ans:-using System;
using System.Collections.Generic;
using System.Text;
namespace codeforevenorodd
{
class Program
{
static void Main(string[] args)
{
int i;
for( i=1; i< 21; i++)
{
if (i % 2 == 0)
{
Console.WriteLine(i);
}
}
Console.ReadLine();
}
}
}
Ans:-using System;
using System.Collections.Generic;
using System.Text;
namespace codeforevenorodd
{
class Program
{
static void Main(string[] args)
{
int i;
for( i=1; i< 21; i++)
{
if (i % 2 == 0)
{
Console.WriteLine(i);
}
}
Console.ReadLine();
}
}
}
This was helpful because you can even do it for ODD number
ReplyDelete1
ReplyDelete