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



Write a program that takes a 5 digit number and calculates 2 power that number and prints it(should..

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

Write a program that takes a 5 digit number and calculates 2 power that number and prints it(should..

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

Post New Answer

More C Interview Questions

WAP to find that given no is small or capital

3 Answers  


I have one doubt. What does below statement mean? #define sizeof(operator) where operator can be int or float etc. Does this statement meaningful and where it can be used?

1 Answers  


What is class and object in c?

0 Answers  


Write a c program to enter a string of paragraph and replacing a particular word which is repeated in the paragraph by another word?

2 Answers   ME, Synfusion, Wipro,


Can a file other than a .h file be included with #include?

0 Answers   Aspire, Infogain,






Find the O/p of the following struct node { char *name; int num; }; int main() { struct node s1={"Harry",1331}; struct node s2=s1; if(s1==s2) printf("Same"); else printf("Diff"); }

1 Answers  


WHO WROTE C LANGUAGE?

4 Answers  


Can an array be an Ivalue?

0 Answers   EXL,


Why is void main used?

0 Answers  


How can you determine the size of an allocated portion of memory?

0 Answers   Aspire, Infogain,


What is sizeof in c?

0 Answers  


int i=0,j; j=++i + ++i ++i; printf(" %d",j);

2 Answers   ME,


Categories