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

how to create c progarm without void main()?

1 Answers   NIIT,


How many types of operators are there in c?

0 Answers  


What is the difference between mpi and openmp?

0 Answers  


Explain how can you be sure that a program follows the ansi c standard?

0 Answers  


Why c is called a middle level language?

0 Answers  






Can we add pointers together?

0 Answers  


What is pointer & why it is used?

0 Answers  


printf("%d",(printf("Hello")); What it returns?

32 Answers   TCS,


main() { int i=0; while(+(+i--)!=0) i-=i++; printf("%d",i); }

4 Answers  


difference between i++* and *++i

6 Answers   IBM,


When you call malloc() to allocate memory for a local pointer, do you have to explicitly free() it?

2 Answers   Aloha Technology,


What are the key features in c programming language?

0 Answers  


Categories