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 |
Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
n=7623 { temp=n/10; result=temp*10+ result; n=n/10 }
I didn't count the ducks that I saw in line, but I do remember that one duck was in front of two ducks, another duck behind two ducks. How many ducks did I see?
When should the const modifier be used?
How can you draw circles in C?
difference between function & structure
What is keyword in c?
Why do we use stdio h and conio h?
#include<stdio.h> void main() { char *str; long unsigned int add; str="Hello C"; add=&str[0]; printf("%c",add); } What is the output?
What is null pointer constant?
Explain the difference between null pointer and void pointer.
can u write a program in C, which does not use = (eqaul)or any arithmatic assignment(like -=,+=,*= etc) operator to swap to number?