Thursday, 14 July 2011

Write a program for calculating the power

class Power
{
          public static void main(String[] arg)
          {
                   int base=Integer.parseInt(arg[0]);
                   int exp=Integer.parseInt(arg[1]);
                   int result=1;
                   for(int i=1;i<=exp;i++)
                   {
                             result=result*base;
                   }
                   System.out.print("Result is="+result);
          }
}

No comments:

Post a Comment

 

About The Author


I am a B.Tech Computer Science Student. I love Programming and blogging. I am Oracle certified Java Professional. Read More
Indian Blogger

Teachers Jobs

Footer 3

Twitter Facebook RSS YouTube Google
​

All Rights Reserved ©Sun Java Masters 2013