C# program to print nth iteration | Csharp Programs
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();
}
C# program to print nth iteration | Csharp Programs
Post a Comment
Click to see the code!
To insert emoticon you must added at least one space before the code.