write a c/c++ program that takes a 5 digit number and
calculates 2 power that number and prints it?

Answers were Sorted based on User's Feedback



write a c/c++ program that takes a 5 digit number and calculates 2 power that number and prints it?..

Answer / parth ujenia

The condition is input take "5 digit" !
and according to above C prog
output of:12345
is: 27825

because range of integer data type is -32768 to 32767.

Is This Answer Correct ?    7 Yes 1 No

write a c/c++ program that takes a 5 digit number and calculates 2 power that number and prints it?..

Answer / m.choudhury

The problem is 2^(axxxx) where x belongs to {0,1,.....9} & a
belongs to {1,2,3,.....9}. This is clearly not equivalent to
2*(axxxx).

The solution will be easier if we can give the answer in
HEXADECIMAL format.

2^2=(4)DEC=(100)BINARY=(4)HEX
2^4=(16)DEC=(10000)BINARY=(10)HEX
2^7=(128)DEC=(10000000)BINARY=(80)HEX
.
.
.
2^n=(X)DEC=(100.....0)BINARY{n no. of zero after 1}=(Z)HEX
(X is the decimal of 2^n, Z is HEXADECIMAL of 2^n)

To get Z get HEX of (1a) where a = n%4 is the number of
zeros after 1.

Then path n/4 no. of zeros with that.

can anyone suggest the code for integer representation of
2^n , (where n is any integer), with polynomial time
complexity ?

Is This Answer Correct ?    1 Yes 0 No

write a c/c++ program that takes a 5 digit number and calculates 2 power that number and prints it?..

Answer / sudarshan

#include<stdio.h>
void main()
{
int a,b;
scanf("%d",&a);
b=a*a;
printf("%d",b);
getch();
}

Is This Answer Correct ?    6 Yes 7 No

write a c/c++ program that takes a 5 digit number and calculates 2 power that number and prints it?..

Answer / suvi

#include<stdio.h>
void main()
{
float a,b;
scanf("%f",&a);
b=a*a;
printf("%.0f",b);

}

Is This Answer Correct ?    2 Yes 3 No

Post New Answer

More C Interview Questions

What is the difference between the = symbol and == symbol?

0 Answers  


Symmetric technologies interview questions. For Computer science candidates the first round is a objective type written test consisting of 16 questions.It is very easy ,any police man can solve this. And next round is a written test consists of both objective and subjective .Total 40 question related to c,c++ and operating system related questions. And then a technical interview and give some program to solve with computer.The md is adamant person, whatever he says we have to accept that is the condition. And one more thing ,,,these interview is just for a formality..the company will select only innocent guys.. the person's without a backbone only they require.. And u have to submit the certificates this is the most important problem...So if you are not getting any other jobs..then only join with this... It is better to try for other company...And apart from that symmetric do a lot of projects..If a candidate can manage everything u can join and make good career with this company... The Md will normally speak rudely..but he is good person and he will give you a lot of very good chances to improve your career....but with cheap salary....

0 Answers   Symmetric Technologies,


What are the advantages and disadvantages of pointers?

0 Answers  


Which is better oop or procedural?

0 Answers  


While(1) { } when this loop get terminate is it a infinite loop?

5 Answers  






A set of N billiard balls are set on a one-dimensional table. The table is 1 meter long, set north-south with two pockets at either side. Each ball has zero width and there is no friction so it is moving with a fixed velocity of either northward or southward and bounces back in a perfect elastic collision from other balls it encounter on its way (or drop into one of the pockets). Your job is to keep track of the balls movements. Task Please write a program that gets the initial place, speed and direction of all the balls and gives the position of a specific ball after t seconds. Input The first line contains the number of scenarios. Each one of the other lines in the input contains a scenario: The first number, N, is the number of balls; followed by N pairs of numbers: the distance in centimeters from the south end of the table and the speed (positive speed meaning it moves northward); the last two numbers are the number i of the target ball you should track and the time T in seconds. Output The output is a single number for each line which is the place (distance in centimeters from the south end of the table) of the tracked ball after T seconds. Note: There is no new line character at the end of the result. Sample Input 5 1 50 1 1 1000 1 50 1 1 6 1 60 -2 1 6 2 10 1 95 -1 2 30 2 10 1 95 -1 2 60 Sample Output 100 56 48 65 70

0 Answers  


what is the use of fflush() function?

2 Answers  


How can you tell whether a program was compiled using c versus c++?

0 Answers  


can we print any string without using terminator?

2 Answers   Infosys, TCS,


Difference between Class and Struct.

13 Answers   Ericsson, Motorola, Wipro,


What is the difference between volatile and const volatile?

0 Answers  


Explain how can I manipulate strings of multibyte characters?

0 Answers  


Categories