Thread: approximate PI help

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    11

    Question approximate PI help

    hello all

    my current project is a program to approximate π (<sorry: its ugly but is pi) up to 1/99
    w/ the usually taylor series representation, eg (π=4x(1-1/3+1/5...etc)

    so far my code is
    Code:
    #include<stdio.h>
    #include<stdafx.h>
    #include"conio.h"
    #include<math.h>
    
    int main()
    {
    double n;
    int i=0;
    
      while(i<100)
      {
      n=(((-1)^i)/(2*i+1));
      i++;
      }
    
    printf(" PI is &#37;lf (debug %d i)", n, i);
    getch();
    return (0);
    }
    which runs but my n seems to stay 0 always... i was wondering if im approaching the problem too simply (quite simple myself) or if i am screwing up somthing (possibly ^ , i tried pow(x,x) config but that ran me into syntax.... anyways thank you for help in advance.
    Last edited by musifuger; 04-01-2008 at 05:57 PM. Reason: spacing

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pi - Hm, somethign is not right here.
    By MadnessRed in forum C++ Programming
    Replies: 8
    Last Post: 09-12-2008, 01:07 PM
  2. PI Equation in C
    By wallysworld in forum C Programming
    Replies: 13
    Last Post: 10-23-2006, 08:12 PM
  3. Pi Calculation
    By EvilGuru in forum C Programming
    Replies: 2
    Last Post: 05-02-2005, 04:25 AM
  4. Pi and the standard library
    By FOOTOO in forum C Programming
    Replies: 7
    Last Post: 04-15-2005, 11:23 AM
  5. C for PI
    By Lynux-Penguin in forum C Programming
    Replies: 13
    Last Post: 04-28-2002, 07:37 PM