write a program that a 5 digit number and calculates 2
power that number and prints it.

Answer Posted / umesh

// This will yield the result if user enters only 5 digit
number.

//import headers

class power
{
public static void main(string args[])
{
system.out.println("Enter 5 digit number : ");
n = system.in.readline();
b =0;
len = n.length();

if(len == 5)
{
a=Integer.ParseInt(n)
for i=0;i<a;i++
{
b = 2*2;

}
system.out.println("2 power entered 5 digit number is :
"+b)
}
else
{
system.out.println("Entered number in more/less than
5 digits")
}

}

//Sorry, not much familiar about the syntax.. but here is
the logic..

Is This Answer Correct ?    3 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Will rust take over c++?

588


How long will it take to learn programming?

582


What is the latest c++ standard?

675


What are punctuators in c++?

642


Why is c++ still best?

549






What are manipulators used for?

603


What are the syntactic rules to be avoid ambiguity in multiple inheritance?

629


Which software is used to run c++ program?

546


What is setf in c++?

574


How to declaring variables in c++?

657


What is DlgProc?

596


Comment on c++ standard exceptions?

630


What is std namespace in c++?

715


What are the advantages of prototyping?

560


Which function cannot be overloaded c++?

573