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
Explain public, protected, private in c++?
What apps are written in c++?
How do I download c++?
What is using namespace std in c++?
Is c++ a good beginners programming language?
What is the need of a destructor?
Define the process of error-handling in case of constructor failure?
Can I learn c++ without knowing c?
What is the difference between reference and pointer?
What is the role of C++ shorthand's?
What is the most powerful coding language?
what is c++
Is c++ an integer?
What do the header files usually contains?
Describe friend function & its advantages.