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)
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / nitin katakdound
int main(int argc, char *argv)
{
long two_power, five_digit_number;
if(scanf("%ld",&five_digit_number)){
two_power = five_digit_number*five_digit_number;}
printf("\n 2 power of that number is %ld",two_power);
return 0;
}
| Is This Answer Correct ? | 13 Yes | 29 No |
Differentiate between the expression “++a” and “a++”?
How we add our function in liabrary as liabrary function. Exp. we want use our int factorical(int); function as int pow(int,int); function working in math header file.
What is a pointer on a pointer in c programming language?
What is the explanation for cyclic nature of data types in c?
How can I sort more data than will fit in memory?
Should I learn data structures in c or python?
how many times does the loop iterated ? for (i=0;i=10;i+=2) printf("Hi\n");
whitch value return void main?
What is array of structure in c programming?
what is call by value and call by reference
What is a MAC Address?
wap to print "hello world" without using the main function.