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

In which mode we open the file for read,write and append also in c ? a)W b)w+ c)r+ d)a

2 Answers   BitWise,


why TCS selected more student in the software field from all institution.

5 Answers   TCS,


How do you define CONSTANT in C?

0 Answers   ADP,


How we can set and clear bit in a byte using macro function?

2 Answers   L&T, Samsung,


who invented c

13 Answers   IBM,


1. main() { printf("%d",printf("HelloSoft")); } Output?

3 Answers   HCL,


code for bubble sort?

1 Answers  


what do u mean by Direct access files? then can u explain about Direct Access Files?

0 Answers   LG Soft,


write a “Hello World” program in “c” without using a semicolon?

9 Answers   CTS, TCS, Wipro,


Describe for loop and write a c program to sum the series X + x2/2! + x3 /3! + …….. up to fifteen terms.

2 Answers  


Write a program for finding factorial of a number.

0 Answers   Tech Mahindra,


what is the difference between #include<stdio.h> and #include"stdio.h" ?

6 Answers   TCS,


Categories