Monday, December 17, 2012

PROGRAM TO GET POWER OF A NUMBER RAISED TO ANOTHER

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication12
{
class Program
 {
static void Main(string[] args)
{
int num, pow, temp;
Console.Write("Enter the number: ");
String strNUM=Console.ReadLine();
num = int.Parse(strNUM);
Console.Write("Enter the power: ");
String strPOW = Console.ReadLine();
pow = int.Parse(strPOW);
temp = num*num;
for (int i = 2; i {
temp = (temp * num);
}
Console.WriteLine("Result= "+temp);
Console.ReadLine();
}
}
}

<<<<<<<<<<<<<<<<<<<<<<<< OUTPUT >>>>>>>>>>>>>>>>>>>>>>>>>>>>

Enter the number:12

Enter the power:2

Result= 144

No comments:

Post a Comment