DIGIT-ARC read-only archive · snapshot: July 23, 2026

A Programming problem faced in an Interview by me

8 posts · originally from https://geek.digit.in/community/threads/a-programming-problem-faced-in-an-interview-by-me.131753/

ten24bytes
ten24bytes Original post #1
Sep 15, 2010 at 7:13 PM
Hi guys,

Recently I gave an interview for a company where I faced an unusual question.

The interviewer asked me to make a program which calculates 2^(any 5 digit no.) in any programming language.

The thing is that what data type to take as he specifically mentioned not to take BigInteger or Exponential types.

Please help me out. It'll be better f it be in C++ or Java.

Thanks in advance!
A
amohit #2
Sep 16, 2010 at 7:36 AM
If you have to make it independent of datatype (and hence language), one possible way I could think of is using linked lists.

Regards,
Mohit
ten24bytes
Sep 16, 2010 at 10:45 AM
@amohit: Well I also thought of that, but even then we would have to make calculations and store individual digits.
How is that possible??
Any example??
Liverpool_fan
Sep 16, 2010 at 5:01 PM
^ ^ ^
You can use a string or array of integers and make changes on them as you make on a piece of paper.
Neuron
Neuron #5
Sep 16, 2010 at 7:15 PM
How about this one?Created in C by me :smile:


#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int pwr,i,val=1,tnpwr=0;
printf("Enter the power");
scanf("%d",&pwr);
for(i=1;i<=pwr;i++)
{
val*=2;
if(val>999999999)
{
val/=10;
tnpwr++;}
}
printf("The value is %dx10^%d",val,tnpwr);
getch();
}
S
Sep 24, 2010 at 9:05 PM
Hi Neuron this is sagar
your program gives an error in turbo c++ complier....(Constant expression is out of range)
Please solve this error
T
Sep 25, 2010 at 12:53 AM
if(val>999999999)
used 9999 worked but didnt get the desired output



Edit : got the output now
asingh
asingh #8
Sep 25, 2010 at 1:30 PM
More of a trick questions. Quite a dumb thing to ask in an interview.

Here see this.

It is testing what you "do not know", instead of "what you know".