Write a program that takes a 5 digit number and calculates
2 power that number and prints it(should not use big
integers and exponential functions)

Answers were Sorted based on User's Feedback



Write a program that takes a 5 digit number and calculates 2 power that number and prints it(should..

Answer / venu

sol 1:
int fun(int i5DigitNum)
{
return 2<< i5DigitNum; // will overflow if the number is > 32
}

sol 2:
//assumption 32 bit machine
temp = i5DigitNum/32 + i5DigitNum%32 == 0 ? 0 :1 ;
char * temp2 = malloc(temp*4)
temp2[0] = 1 << i5DigitNum%32;

// now print this array as number!! :(

Is This Answer Correct ?    4 Yes 4 No

Write a program that takes a 5 digit number and calculates 2 power that number and prints it(should..

Answer / nitin katakdound

int main(int argc, char *argv)
{
long two_power, five_digit_number;

if(scanf("%ld",&five_digit_number)){
two_power = five_digit_number*five_digit_number;}
printf("\n 2 power of that number is %ld",two_power);

return 0;
}

Is This Answer Correct ?    13 Yes 29 No

Post New Answer

More C Interview Questions

what is the difference between #include<> and #include”…”?

5 Answers  


How to establish connection with oracle database software from c language?

0 Answers  


find out largest elemant of diagonalmatrix

0 Answers  


What is the difference between i++ and i+1 ?(in terms of memory)

3 Answers   HCL,


Explain setjmp()?

0 Answers  






what is the differnce between AF_INET and PF_INET?

5 Answers   Systems Plus, Wipro,


Why is c called c?

0 Answers  


What is the use of ?

0 Answers  


main() { int a,b; printf("%d,%d",scanf("%d%d",&a,&b)); } => do u mean above program's output... =>output will be:2,whatever you enter value for b. =>because scanf is a library fn which will return how many arguements it processes, and second value you are right mr.Satya but i found my self unable to understand that for the first time scanf returns the no of successful matches but how for the second time it returns the value of 'b'.while a function should return the same 'r' value every time.

1 Answers   Cisco,


Can one function call another?

0 Answers  


Can a void pointer point to a function?

0 Answers  


What is meant by type casting?

0 Answers  


Categories