Thread: school programming class problem

  1. #1
    uniqueusername
    Guest

    school programming class problem

    We have to write a program to calculate pi, and i realy have no idea where to start. any ideas would be great.

  2. #2
    Lead Moderator kermi3's Avatar
    Join Date
    Aug 1998
    Posts
    2,595
    Well how do you calculate pi on paper? What do you do?
    Kermi3

    If you're new to the boards, welcome and reading this will help you get started.
    Information on code tags may be found here

    - Sandlot is the highest form of sport.

  3. #3
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  4. #4
    TransparentMember correlcj's Avatar
    Join Date
    Jun 2002
    Posts
    378

    Hello!

    We have to write a program to calculate pi, and i realy have no idea where to start. any ideas would be great.
    You can start by defineing Pi.
    Code:
    #include<iostream>
    using namespace std;
    
    define PI 3.14159
    
    int main()
    {
    // stuff
    return 0;
    }
    I hope this helps you get started.
    later
    cj
    "Be formless, shapeless, like water... You put water into a cup, it becomes the cup, you put water into a bottle, it becomes the bottle, you put it in a teapot, it becomes the teapot... Now water can flow, or it can crash, be water my friend."
    -Bruce Lee

  5. #5
    Lead Moderator kermi3's Avatar
    Join Date
    Aug 1998
    Posts
    2,595
    i wouldn'y define pi cause you want to calculate pi in the end
    Kermi3

    If you're new to the boards, welcome and reading this will help you get started.
    Information on code tags may be found here

    - Sandlot is the highest form of sport.

  6. #6
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    1) Pick an algorithm that you want to use to calculate PI.
    2) Implement that algorithm

  7. #7
    Registered User
    Join Date
    Jun 2002
    Posts
    17
    I won't do it for you, but a simple algorithm for Pi calcution is as follows :

    Pi = 4 - 4/3 + 4/5 - 4/7 + 4/9 -... you get the idea. Have fun with this Fourier series.
    Using Dev-C++ beta under Win XP Pro. That or g++ on Mandrake Linux 9.0 .

  8. #8
    Unregistered Leeman_s's Avatar
    Join Date
    Oct 2001
    Posts
    753
    ....finally someone posts with something intelligent (WarBaboon). No offense everyone else

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with friend class declaration in a namespace
    By Angus in forum C++ Programming
    Replies: 2
    Last Post: 12-09-2008, 01:29 PM
  2. Replies: 2
    Last Post: 06-21-2006, 04:23 AM
  3. template class default constructor problem
    By kocika73 in forum C++ Programming
    Replies: 3
    Last Post: 04-22-2006, 09:42 PM
  4. static class problem.
    By Sebastiani in forum C++ Programming
    Replies: 3
    Last Post: 10-16-2002, 03:27 PM
  5. Replies: 3
    Last Post: 12-03-2001, 01:45 PM