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 many keywords are used in c++?

659


What is iterator c++?

632


Which is better c++ or java?

649


Give 10 points of differences between C & C++.

737


Write a program to find the Fibonacci series recursively.

710






What is main function in c++ with example?

651


What is function overloading in C++?

812


C is to C++ as 1 is to a) What the heck b) 2 c) 10

743


What is endl c++?

706


what is c++

1882


Why c++ is the best language?

690


When we use Abstract Class and when we use Interface?where we will implement in real time?

1766


Explain all the C++ concepts using examples.

788


What sorting algorithm does c++ use?

680


Why is main function important?

686