Tuesday, 10 October 2017

java program calculate power of number


import java.util.*;
 public class power
{
  public static void main(String args[])
{
  Scanner p = new Scanner(System.in);
  int pow,num,res=1;
   System.out.println("Enter any number please :");
   num=p.nextInt();
     System.out.println("Enter the power :");
    pow=p.nextInt();
      for(int i=1;i<=pow;i++)
    {
              res*=num;
}
  System.out.println("The result is  :"+res);
}}

0 comments:

Post a Comment