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


Please Help Members By Posting Answers For Below Questions

Why cant I open a file by its explicit path?

593


What is the difference between c and python?

580


What is the purpose of the statement: strcat (S2, S1)?

638


Explain what are preprocessor directives?

623


Write a code of a general series where the next element is the sum of last k terms.

589






How can I handle floating-point exceptions gracefully?

632


Difference between linking and loading?

688


Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?

656


What is signed and unsigned?

638


"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

652


What is a program flowchart?

598


Can i use “int” data type to store the value 32768? Why?

754


Why c is called a middle level language?

634


Explain built-in function?

587


What is the use of header files?

599