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
Why cant I open a file by its explicit path?
What is the difference between c and python?
What is the purpose of the statement: strcat (S2, S1)?
Explain what are preprocessor directives?
Write a code of a general series where the next element is the sum of last k terms.
How can I handle floating-point exceptions gracefully?
Difference between linking and loading?
Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?
What is signed and unsigned?
"C" language developed by "Dennis Ritchie" at AT & T. his remarks are a) too general, too abstract b) could deal with only specific problems c) lost generality of BCPL and B restored d) no remarks
What is a program flowchart?
Can i use “int” data type to store the value 32768? Why?
Why c is called a middle level language?
Explain built-in function?
What is the use of header files?