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

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..

Answer / muz

@ ^^^

long int is not sufficient to hold the result of 2^(5 digit
number).
Even if u take long long <variable>, the result will be
displayed as infinity.

Is This Answer Correct ?    4 Yes 0 No

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

Answer / pradeep

Thank you for giving reply.
But the above program was not correct as Muz said Long int
is not sufficcient to hold result..........

Is This Answer Correct ?    0 Yes 0 No

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

Answer / cheela deepak

integer range is -32 768 to +32 767 so it doesn't display
value of 2^n(5 digit number)

Is This Answer Correct ?    1 Yes 1 No

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

Answer / manish soni bca 3rd year jaipu

#include<stdio.h>
#include<conio.h>
void main()
{
int n,p;
long int ans;
printf("Enter the number ans power");
scanf("%d %d",&n,&p);
ans=1;
while(p>0)
{
ans*=n;
p--;
}
printf("%ld",ans);
getch();
}

Is This Answer Correct ?    0 Yes 0 No

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

Answer / cheela deepak

integer range is not sufficient for given program so result
will not hold

Is This Answer Correct ?    0 Yes 1 No

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

Answer / manish soni bca 3rd year jaipu

o/p is ;
enter the number 11111
2
123454321

Is This Answer Correct ?    0 Yes 1 No

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

Answer / subhashini

void main()
{


long int n,x;
clrscr();
printf(" Enter 5 digit number:");
scanf("%d",&n);
x=2^n;
printf("result: %d",x);
getch();
}

Is This Answer Correct ?    1 Yes 9 No

Post New Answer

More C Interview Questions

pgm to find number of words starting with capital letters in a file(additional memory usage not allowed)(if a word starting with capital also next letter in word is capital cann't be counted twice)

2 Answers   Subex, Wipro,


how to find the binary of a number?

10 Answers   Infosys,


write a c/c++ program that takes a 5 digit number and calculates 2 power that number and prints it?

4 Answers  


Every time i run a c-code in editor, getting some runtime error and editor is disposing, even after reinstalling the software what may be the problem?

2 Answers  


How can you check to see whether a symbol is defined?

0 Answers  






What is difference between array and pointer in c?

0 Answers  


how to get starting address of a running C program

3 Answers  


Which header file should you include if you are to develop a function which can accept variable number of arguments?

0 Answers   TCS, TISL,


Should a function contain a return statement if it does not return a value?

0 Answers  


Input is "rama loves rajesh and rajesh Loves rama also and rajesh wear gloves and bloves" To print output is count the numbers of times repeted the word love without case sensitive.

0 Answers  


if the total selling price of 15 items and the total profit earned on them is input through the keyboard, write a program to find the cost price of one of the item

2 Answers  


How do you use a pointer to a function?

0 Answers  


Categories