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
Is it possible to initialize a variable at the time it was declared?
A character flag or control mechanism that delineates one data item from another a) variable b) constant c) delimiter d) call by reference
int far *near * p; means
.find the output of the following program? char*myfunc(char*ptr) { ptr +=3; return (ptr); } int main() { char*x,*y; x="HELLO"; y=myfunc(x); printf("y = %s ",y); return 0; }
What is assert and when would I use it?
What is the size of structure pointer in c?
What is printf () in c?
What is the size of array float a(10)?
write a progrmm in c language take user interface generate table using for loop?
When should the register modifier be used? Does it really help?
What are file streams?
Why clrscr is used in c?
What is merge sort in c?
What are compound statements?
what is event driven software and what is procedural driven software?