This one i fail syntax because pow, i still cant find an example that clears it up for me.
Code:
#include<stdio.h>
#include<stdafx.h>
#include"conio.h"
#include<math.h>
int main(void)
{
double n=0.0;
int i=0;
while(i<100)
{
n= pow((-1), i)/((2*i)+1);
++i;
}
printf(" PI is %lf (debug %d i)", n, i);
getch();
return (0);
}
and i have tried to play w/ it this way also but i get "Error 1 error C2296: '/' : illegal, left operand has type 'void' f:\microsoft visual studio 8\projects\7 pi\7 pi\7 pi.cpp 21"
and im sure its because i dont understand the pow also...
Code:
#include<stdio.h>
#include<stdafx.h>
#include"conio.h"
#include<math.h>
void
pow1(double x, int i)
{
pow(x, i);
}
int main(void)
{
double n=0.0 ,x=-1;
int i=0;
while(i<100)
{
n= pow1(x, i)/(2*i+1);
++i;
}
printf(" PI is %lf (debug %d i)", n, i);
getch();
return (0);
}
i have seen a few posts talking about making the pow thru a loop, and not sure if this is easier i have tried to get it going but sadly have lost my code for this as of now: /
sorry to be thick of skull but any help would help... also for the debug im still getting 0 for n even w/ a print for 'n' inside the while loop.