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

How long does it take to get good at leetcode?

0 Answers  


What are the differences between a struct and a class in C++?

7 Answers   Amazon, Wipro,


What is difference between initialization and assignment?

12 Answers   HCL, HP, Infosys,


Explain how the virtual base class is different from the conventional base classes of the opps.

0 Answers  


What is difference between c++ 11 and c++ 14?

0 Answers  


Write a Program to find the largest of 4 no using macros.

0 Answers  


Assume studentNames and studentIDs are two parallel arrays of size N that hold student data. Write a pseudocode algorithm that sorts studentIDs array in ascending ID number order such that the two arrays remain parallel.

0 Answers  


How the delete operator differs from the delete[]operator?

0 Answers  


What is srand c++?

0 Answers  


What is an orthogonal base class in c++?

0 Answers  


Can we use struct in c++?

0 Answers  


Which algorithm do you like the most? Why?

2 Answers   Google,


Categories