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
What are friend classes?
Is there any function that can skip certain number of characters present in the input stream?
Explain explicit container.
What is object file? How can you access object file?
Can a constructor be private?
Is swift faster than c++?
If you hear the cpu fan is running and the monitor power is still on, but you did not see anything show up in the monitor screen. What would you do to find out what is going wrong?
What is iomanip c++?
Can I learn c++ without learning c?
We all know that a const variable needs to be initialized at the time of declaration. Then how come the program given below runs properly even when we have not initialized p?
What do you mean by persistent and non persistent objects?
What is function overloading in C++?
What is the last index number in an array of 100 characters a) 100 b) 99 c) 101
Should a constructor be public or private?
Can notepad ++ run c++?