calculate fractions

This is a discussion on calculate fractions within the C Programming forums, part of the General Programming Boards category; I wand to find a program that calculates the sum of fractions: 1/1 + +1/3 +1/4 + 1/5 + ...

  1. #1
    Registered User
    Join Date
    Nov 2012
    Posts
    1

    calculate fractions

    I wand to find a program that calculates the sum of fractions:
    1/1 + +1/3 +1/4 + 1/5 + .. + 1/100

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,448
    Why not write the program yourself?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,794
    Do you have an actual question or are you hinting that your web-search-fu skills need some help?
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  4. #4
    Registered User
    Join Date
    Jun 2011
    Posts
    2,241
    If that's all you want, then you can do it in a simple spreadsheet program.

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,452
    "find" a program?
    Have you tried looking down the back of the settee, or perhaps underneath the bed?

    Announcements - C Programming
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  6. #6
    Registered User
    Join Date
    Nov 2012
    Posts
    1,053
    Use a for loop

    Code:
    for (int denom=1; denom <= 100; denom++) {
    // TODO
    }
    In the TODO part you should be able to "find" a statement such that your sum variable is updated to a new sum based on the current value of denom.

  7. #7
    Registered User
    Join Date
    Nov 2012
    Posts
    21
    What do you mean "find" a program? Are you trying to find someone to write a program for you?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. need help with fractions in C++
    By Agnes Roguska in forum C++ Programming
    Replies: 43
    Last Post: 02-19-2012, 04:26 PM
  2. Fractions are just = to 0
    By Macca in forum C Programming
    Replies: 1
    Last Post: 05-10-2011, 05:41 AM
  3. fractions
    By joeshmoe1337 in forum C Programming
    Replies: 21
    Last Post: 09-11-2004, 01:34 AM
  4. Fractions
    By Aakash Datt in forum C++ Programming
    Replies: 8
    Last Post: 04-30-2003, 07:36 PM
  5. Fractions
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 04-01-2002, 06:51 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21