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
How many keywords are used in c++?
What is iterator c++?
Which is better c++ or java?
Give 10 points of differences between C & C++.
Write a program to find the Fibonacci series recursively.
What is main function in c++ with example?
What is function overloading in C++?
C is to C++ as 1 is to a) What the heck b) 2 c) 10
What is endl c++?
what is c++
Why c++ is the best language?
When we use Abstract Class and when we use Interface?where we will implement in real time?
Explain all the C++ concepts using examples.
What sorting algorithm does c++ use?
Why is main function important?