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)
Answer Posted / 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 |
Post New Answer View All Answers
What should malloc() do?
Write a program in c to replace any vowel in a string with z?
Difference between linking and loading?
why arguments can generally be passed to functions a) sending the values of the arguments b) sending the addresses of the arguments c) a & b d) none of the above
Please send me WIPRO technical question to my mail ID.. its nisha_g28@yahoo.com please its urgent
Explain threaded binary trees?
Differentiate between functions getch() and getche().
What are control structures? What are the different types?
How can I get back to the interactive keyboard if stdin is redirected?
What is scope and lifetime of a variable in c?
What is a null pointer assignment error? What are bus errors, memory faults, and core dumps?
What is an array in c?
What is the collection of communication lines and routers called?
Why we use void main in c?
Explain what is the use of a semicolon (;) at the end of every program statement?