Searching...
1 Des 2013

C# program to print nth iteration | Csharp Programs

14.17
C# program to print 1 2 4 8 16 21 64 128 …nth iteration

Program Statement:
Write a program using for loop which prints the following series.
1 2 4 8 16 21 64 128 …nth iteration

Solution:

static void Main(string[] args)
{
int n,i=1,num=1;
Console.WriteLine("Enter Value of n ");
n = Convert.ToInt32(Console.ReadLine());
Console.Write(i+" ");
for (i = 1; i <= n; i++)
{
num = num * 2;
Console.Write(num + " ");
}

Console.ReadLine();
}


0 komentar:

Posting Komentar

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.