Thread: A program

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

    Join Date
    Dec 2013
    Posts
    1
    Rep Power
    0

    A program


    To write a C program to calculate the following sum;
    sum=1+x2/2!+x4/4!...... upto given n terms
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,607
    Rep Power
    4247
    So what have you written so far?
    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
  4. #3
  5. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,109
    Rep Power
    1802
    The question of "what compiler should I recommend to my readers?" is perfectly legitimate without the subterfuge - what made you think that was necessary?

    There is nothing "unofficial" about Orwell Dev-C++. Dev-C++ was always open-source and anyone was free to fork it. When it became no longer maintained by Bloodshed, Orwell picked up the batton. Bloodshed Dev-C++ should certainly be avoided.

    It's fine, it is not however a compiler. It is an IDE. It is distributed with MinGW GCC which is as good a C++ compiler as any.

    The biggest problem with Bloodshed Dev-C++ was its debugger (or rather its integration with GDB), it was buggy and very limited. I do not know whether Orwell has improved that.

    Another problem with Dev-C++ (all variants) is that it is written in Delphi, so has never attracted a large number of developers to maintain and enhance the project.

    A good alternative is Code::Blocks. This too is an IDE which on Windows is distributed with MinGW, but it is more fully featured, more widely supported, cross platform, and has a working debugger.

    Personally however I'd recommend VC++ Express Edition. It is free, very well featured, and has about the best debugger in the business.
  6. #4
  7. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,376
    Rep Power
    1871
    Perhaps you can see the obviousness of the loop, if you understand that the first term can also be written as

    X^0/0!
    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. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,109
    Rep Power
    1802
    What is the relationship between n and the nth term? From the example it is not clear whether the series is:

    0, 2, 4, 6, 8, ... (i..e all even numbers)

    or

    1, 2, 4, 8, 16, ... (i.e. all powers of two)

    or something else entirely.

IMN logo majestic logo threadwatch logo seochat tools logo