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

How long does it take to get good at leetcode?

652


What is & in c++ function?

584


What are special characters c++?

562


Draw a flow chart and write a program for the difference between the sum of elements with odd and even numbers. Two dimensional array.

5893


What are smart pointers?

666






What is singleton class in c++?

588


If all is successful, what should main return a) 0 b) 1 c) void

554


What does floor mean in c++?

576


Why pointer is used in c++?

608


What are the advantages of using const reference arguments in a function?

608


What is the use of main function in c++?

520


What is the difference between map and hashmap in c++?

553


What is data binding in c++?

501


Do vectors start at 0?

588


What is the difference between global variables and static varables?

563