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
a function gets called when the function name is followed by a a) semicolon (;) b) period(.) c) ! d) none of the above
What is register variable in c language?
What is a static function in c?
Is that possible to store 32768 in an int data type variable?
Differentiate between #include<...> and #include '...'
What is the general form of function in c?
Do variables need to be initialized?
What is the process of writing the null pointer?
What are the Advantages of using macro
How many parameters should a function have?
How do I use void main?
A variable that is defined in a specified portion of a program but can be used throughout the program a) global variable b) local variable c) character d) none
What does the function toupper() do?
Explain union. What are its advantages?
What is c language and why we use it?