Thread: Please help!!!

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2007
    Posts
    4
    Rep Power
    0

    Please help!!!


    The Fibonacci sequence problem: The Fibonacci sequence is the series of numbers 0, 1, 1, 2, 3, 5, 8, .... Formally, it can be expressed as:

    fib0 = 0
    fib1 = 1
    fib2 = fibn-1 + fibn-2

    Write a C program using the fork() system call that generates the Fibonacci sequence in the child process. The number of the sequence will be provided in the command line. For example, if 5 is provided, the first five numbers in the Fibonacci sequence will be output by the child process. Because the parent and child processes have their own copies of the data, it will be necessary for the child to output the sequence. Have the parent invoke the wait() call to wait for the child process to complete before exiting the program. Perform necessary error checking to ensure that a non-negative number is passed on the command line.

    Comments on this post

    • animatronic disagrees : what's the question?
    • sizablegrin disagrees : Please read the "How to Post a Question" thread. That would be the one that says, "READ THIS FIRST". Your subject line sucks in terms of searchability for subsequent users.
    • Yahweh disagrees : Do your own homework, idiot.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2007
    Posts
    4
    Rep Power
    0
    No question, i just want the code of this.A programm to calculate fibonacci...
  4. #3
  5. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,594
    Rep Power
    4207
    Ah you've come to the correct place then.
    Please see the attached program. You'll need a linux system to compile this. To use, simply read from /dev/fibonacci

    Comments on this post

    • Lux Perpetua agrees : Are you trying to make us look forward to these threads now? :-)
    • codergeek42 agrees : Excellent work!
    Attached Files
    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
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    San Francisco Bay
    Posts
    1,939
    Rep Power
    1313
    It's pretty easy. What part of it are you having trouble with?
  8. #5
  9. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,594
    Rep Power
    4207
    @Lux Perpetua: It does work :). I thought the original poster might appreciate the fact that it is implemented as a Linux device driver. So in case you want to send a stream of fibonacci numbers to a modem, you could simply use a shell script to do:
    cat </dev/fibonacci >/dev/modem

    Think of the possibilities! The world could really use a fibonacci device driver :)
    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
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    San Francisco Bay
    Posts
    1,939
    Rep Power
    1313
    I figured as much. As fas as I can tell, your code examples, however far-fetched, are always fully functional.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2007
    Posts
    4
    Rep Power
    0
    thanx!!!

    Comments on this post

    • Schol-R-LEA agrees : And won
  14. #8
  15. Commie Mutant Traitor
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2004
    Location
    Norcross, GA (again)
    Posts
    1,804
    Rep Power
    1569
    Originally Posted by funkyjohny
    thanx!!!
    And won't your professor be surprised... :tblue:
    Rev First Speaker Schol-R-LEA;2 JAM LCF ELF KoR KCO BiWM TGIF
    #define KINSEY (rand() % 7) λ Scheme is the Red Pill
    Scheme in Short Understanding the C/C++ Preprocessor
    Taming Python A Highly Opinionated Review of Programming Languages for the Novice, v1.1

    FOR SALE: One ShapeSystem 2300 CMD, extensively modified for human use. Includes s/w for anthro, transgender, sex-appeal enhance, & Gillian Anderson and Jason D. Poit clone forms. Some wear. $4500 obo. tverres@et.ins.gov
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2007
    Posts
    4
    Rep Power
    0
    We 'll find out in about 12 hours!!!
  18. #10
  19. Commie Mutant Traitor
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2004
    Location
    Norcross, GA (again)
    Posts
    1,804
    Rep Power
    1569
    This is too much; while I'm all for letting fools walk into wood chippers, I would have thought that the rest of the responses would have made it clear that S4E wasn't serious about that. I mean, did you even look at the code? The documentation states outright who wrote it originally, and it uses techniques which are far, far above what you're class is using if you are still working in the Fibonacci problem. While it does what you asked for, submitting it for a homework assignment would be like holding a large flashing sign saying "PLAGIARIST!" over your head.

    You haven't given it to your teacher already, I hope?

    /me Looks at time when FunkyJohny posted his last message

    Oh, my. I guess you probably will have by the time you read this, though I suppose you might check over here at some point in the remaining three hours. Well, consider it an object lesson in the importance of academic honesty, I suppose.
    Last edited by Schol-R-LEA; November 4th, 2007 at 02:20 PM.
    Rev First Speaker Schol-R-LEA;2 JAM LCF ELF KoR KCO BiWM TGIF
    #define KINSEY (rand() % 7) λ Scheme is the Red Pill
    Scheme in Short Understanding the C/C++ Preprocessor
    Taming Python A Highly Opinionated Review of Programming Languages for the Novice, v1.1

    FOR SALE: One ShapeSystem 2300 CMD, extensively modified for human use. Includes s/w for anthro, transgender, sex-appeal enhance, & Gillian Anderson and Jason D. Poit clone forms. Some wear. $4500 obo. tverres@et.ins.gov

IMN logo majestic logo threadwatch logo seochat tools logo