Please plz plz i need help

Pages: 12
zereo do you have a problem with me ?!!?!! ...relax...dear.
..it's written on C++ Book pearsn...and i cant use what he gave me because it my 3rd week i c++ so im not bill gates to use for and pow because i dont know it. All what i was want some ideas to not copy and patse codes...!! anw sry dear :)...!
double pi=0.0 i
int N,
int d=1;
int i=1:
cout<< "enter num of terms":
cin>>N
while(i<=N)
{ (if i%2==1)
pi+=4.0/d:
else pi-=4.0/d;
d+=2
i++;
}
Last edited on
This page explains both the while loop and the for loop, with examples. These can be considered some of the basic building blocks of any program, so its worth getting familiar with these ideas before returning to the original question.
http://www.cplusplus.com/doc/tutorial/control/
@TheIdeasMan

Many Thanks for your reflections.
I'm at the beginning of C++ programming.
So any idea is good for me from which I can learn new things.

@abzksm

Also the Leibniz method for calculating PI does not converge very well - so you need a lot of terms to get relatively few decimal places. That is why it didn't seem to work when you ran the code the first time.

Hope all goes well.
If you can't do something with your current level of understanding keep learning and try later.
Topic archived. No new replies allowed.
Pages: 12