write a program that a 5 digit number and calculates 2
power that number and prints it.
Answers were Sorted based on User's Feedback
Answer / ayushi rastogi
/* We assume that user enter 5 digit No */
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
double No,length=2;
double pwrNo;
printf("Please Enter the 5 digit No.:");
printf("\n");
scanf("%d",&No);
pwrNo=pow(No,2);
printf("\n");
printf("Power of %u No is %u",No,pwrNo);
}
| Is This Answer Correct ? | 6 Yes | 5 No |
Answer / 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 |
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?
Which command properly allocates memory a) char *a=new char[20]; b) char a=new char[20]; c) char a=new char(20.0);
find the two largest values among the 6 numbers using control structures : do-while,for,if else,nestedif- else ,while. one or two of them.
what is the emaning of '#include" "'?
What is the exit function in c++?
What is data type in c++?
Does there exist any way to make the command line arguments available to other functions without passing them as arguments to the function?
Can we declare destructor as static? Explain?
What is the default width for ouputting a long integer using the insertion operator?
What is a class definition?
What are activex and ole?
How do you remove an element from a set in c++?