Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    5
    Rep Power
    0

    How to convert Integer to String /to find Length of integer value


    HI every body.. recently i cleared an interveiw for internship and assigned a task. i am trying fior 2 days but in vain. task is: to create an application that takes integer value from user from 1 to 1billion an returns its string value. e.g if user enter 1567 it will display One Thousand five Hundred Sixty Seven..
    please help me,with the code of this program in c or c++

    regards: ahmed
    thanx for your time :(
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    84
    Rep Power
    2
    Originally Posted by softengr3248
    HI every body.. recently i cleared an interveiw for internship and assigned a task. i am trying fior 2 days but in vain. task is: to create an application that takes integer value from user from 1 to 1billion an returns its string value. e.g if user enter 1567 it will display One Thousand five Hundred Sixty Seven..
    please help me,with the code of this program in c or c++

    regards: ahmed
    thanx for your time :(
    sounds pretty simple to me...

    did u even try?

    Comments on this post

    • salem agrees : A sound observation - always get the OP to make the first move
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    5
    Rep Power
    0
    then please post the code . i tried but i could not as i am at very begineer level
  6. #4
  7. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,392
    Rep Power
    1871
    > i am trying fior 2 days but in vain.
    So post your latest effort.
    We don't know whether you're "almost there" or "way off".

    > recently i cleared an interveiw for internship
    So your bluff has been called
    My guess is you don't really know anything, but you managed to bluff your way through the interview with a few memorised phrases.

    Faced with the reality of actually having to write some code, you're out of your depth.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    5
    Rep Power
    0

    please someone post the code..please please please


    :(
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    5
    Rep Power
    0

    @salem


    you are right sir that i have cleared interveiw by some memorised lines and dont know any practical field, but m nor bluffing, i know yu r not insulting me but inspiring me to do something better. but really i am unable to do. once i get the code i will understand it,, i created a logic af this, to make an arry ,counting the number of digits in it so exact amount will bw known, but how should i print them with hundreds,thousands,milllions and billlions??

    Comments on this post

    • ptr2void disagrees : Enjoy your failure, you are a liar and a cheater.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    84
    Rep Power
    2
    now that i tried it, its not exactly that simple either... :D
  14. #8
  15. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,638
    Rep Power
    4247
    If you search carefully, you'll find the solution here. I implemented this in both PHP and C on this forum many years ago.
    Last edited by Scorpions4ever; December 27th, 2012 at 08:02 AM.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    5
    Rep Power
    0

    @all


    can yu just send me the code please in c? i will be very very thankful to yu please try to understand i really need it please
  18. #10
  19. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,895
    Rep Power
    481
    I recommend log10 to find the number of digits.
    [code]Code tags[/code] are essential for python code and Makefiles!
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    84
    Rep Power
    2
    Originally Posted by softengr3248
    can yu just send me the code please in c? i will be very very thankful to yu please try to understand i really need it please
    here's for the "millions" part..
    you'll have to add the "thousands", "hundreds" and tens/units yourself in the same way...

    And note: I only used simple "if" and "else if" commands...

    here is the link, its in txt format:

    <delinked>

    Also, you didn't mention any size limits etc for the program...the one I have wrote is waaaay longer than it could have been...

    And btw you are the "gimme teh codez" kind of person... :p
    Last edited by Scorpions4ever; December 27th, 2012 at 11:37 AM.
  22. #12
  23. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,392
    Rep Power
    1871
    Originally Posted by softengr3248
    can yu just send me the code please in c? i will be very very thankful to yu please try to understand i really need it please
    No, what you need to do is face up to the reality that you're in a position you can't possibly hope to maintain in the long term.

    What are you going to do next week - come begging again with the next work assignment which you're equally clueless about. Simply giving you the answer just perpetuates the pointless cycle you've managed to get yourself stuck in.

    People like you are a waste of space at the coal face of programming. Your only hope is to get promoted past the point where you need to know anything technical before you get fired for incompetence.

    For everyone else, A spotters guide
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  24. #13
  25. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    29
    Rep Power
    0
    for the above question ...should it be a for loop of simply if ..else ..
  26. #14
  27. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    77
    Rep Power
    0
    yeah it should be condition with a loop even a simple condition do it sir then they will help you to do it ... there's so many master here that teach you how to do it ...
  28. #15
  29. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    84
    Rep Power
    2
    im not sure, maybe posting links is not allowed, so here's the code that I wrote earlier...

    [edit]Please don't feed answers to someone who has not shown *ANY* effort in solving the problem on his/her own.

    Thanks in advance[/edit]
    Last edited by Scorpions4ever; December 28th, 2012 at 05:07 AM.
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo