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 default value of global variable in c?

0 Answers  


how can you print&scan anything using just one character? :) HINT: printf,scanf similer

2 Answers  


A routine usually part of the operation system that loads a program into memory prior to execution a) linker b) loader c) preprocessor d) compiler

0 Answers  


How many keywords (reserve words) are in c?

0 Answers  


find the output? void r(int a[],int c, int n) { if(c>n) { a[c]=a[c]+c; r(a,++c,n); r(a,++c,n); } } int main() { int i,a[5]={0}; r(a,0,5); for(i=0;i<5;i++) printf("\n %d",a[i]); getch(); }

0 Answers   Microsoft,






How is a pointer variable declared?

0 Answers  


Write a program to print this triangle: * ** * **** * ****** * ******** * ********** Don't use printf statements;use two nested loops instead. you will have to use braces around the body of the outer loop if it contains multiple statements.

6 Answers   Wipro,


without using arithmatic operator convert an intger variable x into x+1

3 Answers  


What is an operator?

0 Answers  


#include<stdio.h> void main() { char *str; long unsigned int add; str="Hello C"; add=&str[0]; printf("%c",add); } What is the output?

4 Answers   Infosys,


Is fortran still used today?

0 Answers  


What is difference between structure and union with example?

0 Answers  


Categories