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



write a program that a 5 digit number and calculates 2 power that number and prints it...

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

write a program that a 5 digit number and calculates 2 power that number and prints it...

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

Post New Answer

More C++ General Interview Questions

What are the three forms of cin.get() and what are their differences?

0 Answers  


Explain the concept of copy constructor?

0 Answers  


Write a C program to calculate the salary of each employee in your company. You need to input the hours worked and the hourly rate. The company pays 1.5 times the hourly rate for all hours worked in excess of 48 hours. Use the formulas below to calculate the salary: if employee worked less than 48 hours salary = hours * rate; if employee worked more than 48 hours salary = 48.0 * rate + ( hours &#8722; 48.0 ) * rate * 1.5; You are required to use a loop to produce the sample output as given below.

1 Answers  


Show the declaration for a pointer to function returning long and taking an integer parameter.

0 Answers  


What is & in c++ function?

0 Answers  






What is implicit conversion/coercion in c++?

1 Answers  


What is a hash function c++?

0 Answers  


what is the size of this class class size { public: char data1; double d; int data2; char data3; double data4; short data5; }; please explain the padding for these double variables.

9 Answers  


Why is c++ so fast?

0 Answers  


What are advantages and disadvantages of Design patterns?

7 Answers   IBM, Vodafone,


What is a down cast?

0 Answers  


What are literals in C++?

0 Answers   Wipro,


Categories