a). 1, 5, 10 ,15, 20
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace series1
{
Class Program
{
static void main(string[] args)
{
int n, i=1, mul=1;
Class Program
{
static void main(string[] args)
{
int n, i=1, mul=1;
Console.WriteLine("How many number.");
n = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("{0}",i);
for(i = 1; i<=n ;i++)
{
mul = i* 5;
Console.WriteLine("{0}", mul);
}
Console.ReadLine();
}
}
}
OUTPUT:
How many numbers.
5
1
5
10
15
20
25
b). 0, 2, 4, 6
using System;
using System.Collections.Generic;using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace series2
{
Class Program
{
static void main(string[] args)
{
int n, i;
Console.WriteLine("Enter how many terms.");
n= Convert.ToInt32(Console.ReadLine());
for(i=0; i<n; i++)
{
if (i%2 == 0)
{
Console.WriteLine("{0}", i);
}
Console.ReadLine();
}
}
}
OUTPUT:
Enter how many terms.
8
0
2
4
6
c). 0, 1, 1, 2, 3, 5,7......
using System;
using System.Collections.Generic;using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace series3
{
Class Program
{
static void main(string[] args)
{
int i, n, first=0, second = 1, third;
Console.WriteLine("How many terms.");
n = Covert.ToInt32(Console.ReadLine());
Console.WriteLine("{0}",first);
Console.WriteLine("{0}",second);
for(i=0; i< n-2; i++)
{
third = first + second;
Console.WriteLine("{0}", third);
first = second;
second = third;
}
Console.ReadLine();
}
}
}
OUTPUT:
How many terms.
7
0
1
1
2
3
5
8
Comments
Post a Comment