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
Declare a class vehicle and make it an abstract data type.
what are Operators and explain with an example?
What is a tuple c++?
Which is the best c++ compiler?
What is the use of class in c++?
What are c++ templates used for?
Discussion on error handling of C++ .
What is encapsulation in c++?
What does scope resolution operator do?
what are the iterator and generic algorithms.
What are register variables?
Why is c++ still best?
How do I write a c++ program?
What is algorithm in c++ programming?
Which one between if-else and switch is more efficient?