Jumat, 29 April 2016

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();
}


0 komentar to “C program to print nth iteration Csharp Programs”

Posting Komentar

 

Make Money Online Now Free Copyright © 2016 -- Powered by Blogger