Program which reads two numbers and displays the result of exponentiation of the first number by the second.

import java.io.*;
class Expo
{ public static void main(String[] a)throws IOException
{
BufferedReader obj=new BufferedReader(new InputStreamReader(System.in));
int x,y,expo=1;
String num;
System.out.println("Enter the the base and power::");
num=obj.readLine();
x=Integer.parseInt(num);
num=obj.readLine();
y=Integer.parseInt(num);
for(int i=0; i<y;i++)
{
expo= x*expo;
}
System.out.println("The Result of exponention= "+expo+".");
}
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s