Write a C# Program to Calculate Power of Three

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Collections;

using System.Threading;

using System.IO;



namespace CSharpProgram

{


    public class GeneratePowersofNum

    {

        public void GeneratePower(int max, int power)

        {

            Console.WriteLine("Number\tPower of " + power);


            for (int i = 1; i <= max; i++)

            {

                double result = Math.Pow(i, power);

                Console.WriteLine(i + "\t" + result);

            }

        }

    }

    class AkbTechie

     {

            static void Main(string[] args)

           {

               GeneratePowersofNum obj = new GeneratePowersofNum();

               obj.GeneratePower(7, 3);

               Console.ReadKey(); 

          }

    }

}



output:-

Number  Power of 3

1       1

2       8

3       27

4       64

5       125

6       216

7       343

एक टिप्पणी भेजें

0 टिप्पणियाँ