Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Reply
 
LinkBack Thread Tools Display Modes
Old 15-09-2010, 07:13 PM   #1 (permalink)
asia://india/ka/bangalore
 
a_to_z123's Avatar
 
Join Date: Nov 2004
Location: Bangalore, India
Posts: 293
Question A Programming problem faced in an Interview by me


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!
__________________
:) I've got my F, C and K . Now all I need is You !!! :)
a_to_z123 is offline   Reply With Quote
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 16-09-2010, 07:36 AM   #2 (permalink)
Right Off the Assembly Line
 
Join Date: Aug 2008
Posts: 35
Default Re: A Programming problem faced in an Interview by me

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
amohit is offline   Reply With Quote
Old 16-09-2010, 10:45 AM   #3 (permalink)
asia://india/ka/bangalore
 
a_to_z123's Avatar
 
Join Date: Nov 2004
Location: Bangalore, India
Posts: 293
Default Re: A Programming problem faced in an Interview by me

@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??
__________________
:) I've got my F, C and K . Now all I need is You !!! :)
a_to_z123 is offline   Reply With Quote
Old 16-09-2010, 05:01 PM   #4 (permalink)
Sami Hyypiä, LFC legend
 
Liverpool_fan's Avatar
 
Join Date: Jun 2007
Location: Нью-Дели
Posts: 2,138
Default Re: A Programming problem faced in an Interview by me

^ ^ ^
You can use a string or array of integers and make changes on them as you make on a piece of paper.
__________________
Experience true education in Computer Science - http://www.udacity.com | http://www.coursera.org

Spoiler:
Read before asking / messaging any moderator for any query: FAQ + answers for new members

Read all the sticky threads before asking any type of query. Most basic questions are answered in those.
Don't use forum for chatting. Visit http://webchat.freenode.net/?channels=krow, enter nick and connect.
Liverpool_fan is offline   Reply With Quote
Old 16-09-2010, 07:15 PM   #5 (permalink)
Electronic.
 
Neuron's Avatar
 
Join Date: Jun 2010
Location: Elsweyr
Posts: 530
Default Re: A Programming problem faced in an Interview by me

How about this one?Created in C by me


#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();
}
__________________
I don't always make sense,but when I do,I don't.
Neuron is offline   Reply With Quote
Old 24-09-2010, 09:05 PM   #6 (permalink)
Right Off the Assembly Line
 
Join Date: Sep 2010
Posts: 1
Default Re: A Programming problem faced in an Interview by me

Hi Neuron this is sagar
your program gives an error in turbo c++ complier....(Constant expression is out of range)
Please solve this error
sagar1099 is offline   Reply With Quote
Old 25-09-2010, 12:53 AM   #7 (permalink)
Broken In
 
Join Date: May 2009
Location: BANgalore
Posts: 118
Default Re: A Programming problem faced in an Interview by me

Quote:
if(val>999999999)
used 9999 worked but didnt get the desired output



Edit : got the output now
tejaslok is offline   Reply With Quote
Old 25-09-2010, 01:30 PM   #8 (permalink)
Super Moderator
 
asingh's Avatar
 
Join Date: May 2008
Location: New Delhi
Posts: 5,548
Default Re: A Programming problem faced in an Interview by me

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".
__________________
MSI P45 Platinum(BIOS v1.7B)|Q9550[E0]@3.85Ghz@1.320V[453x8.5]MCH@1.184V|ICH@1.55V|DDR_V_Ref_A_B@1.05V|NH-D14|Corsair TWIN2X4096-8500C5(5-5-5-15)@1089Mhz@2.14V
2xHD4890[Xfire]@1000/900[MEM/GPU]|Corsair 650TX|Seagate180GB+80GB+WD1TB|SONY-DVD-R|CM690|2x120mm Scythe Ultra Kaze|DELL S2409W|APC 1100VA|Scythe Kaze Server
Windows 7 Ultimate RTM - 64BIT|Catalyst 10.5 (8.14.10.0753) forced with RadeonPRO|PS3 160GB|Sony 40EX520|AC Ryan POHD Mini|APC 800VA|APC 800VA|D425KT|CM100 Elite|2TB WD|Acer D255

Test your spoiler tags before submitting
asingh is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lan problem in win xp ARJOT SINGH Software Q&A 1 08-09-2010 10:55 PM
Odd problem : Need Help Anx02 Hardware Q&A 22 22-08-2010 01:52 PM
Ubuntu 10.04 "Low Graphics Mode" problem after update krishnandu.sarkar Open Source 6 23-05-2010 05:35 AM
problem with 16GB Cruzer micro rohit330 Hardware Q&A 3 16-05-2010 08:59 PM
Wierd LCD problem Psychosocial Hardware Q&A 2 10-03-2010 02:20 AM

 
Latest Threads
- by Charan
- by Charan
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 03:22 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2