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

Discuss the effects occur, after an exception thrown by a member function is unspecified by an exception specification?

828


Write syntax to define friend functions in C++.

810


What is the fastest c++ compiler?

770


How would you use qsort() function to sort an array of structures?

904


Can we use this pointer in a class specific, operator-overloading function for new operator?

817


What is purpose of abstract class?

784


What is scope resolution operator in c++ with example?

780


What is the difference between interpreters and compilers?

839


Give example of a pure virtual function in c++?

798


Should you pass exceptions by value or by reference?

904


How a pointer differs from a reference?

962


What do you mean by const correctness?

824


Explain the different access specifiers for the class member in c++.

741


Explain the use of this pointer?

887


When do we run a shell in the unix system?

807