Hi all, this is my first post (possibly ever, can't remember when i last came on =P)
Anyways, I am fairly good in the C language, far from expert.

I got the idea of making a program that calculates pi. I made it and using a long double, I could calculate pi accurately to 19 decimal places, which makes total sense considering I was using a long double.

So I wasn't satisfied, and realized that to accomplish anything better than 19 decimal places, I would need to use GMP.

So I installed GMP for DevC++ on Windows 7. All goes well, I even tested some examples I found online.

So after reading the GMP manual, as well as countless examples of GMP code online, this is all I've been able to do. If anybody doesn't mind looking, that would be great. I just ask that nobody gives me the answer on a silver platter, I really want to learn this, and I just couldn't do it on my own. If anybody has the time to help, i would appreciate guidance on which GMP functions to use, and why I should be using them.

Sorry for such a long intro. Here is the code I have been able to write with the knowledge I gained from reading the GMP manual and examples online:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <GMP.h>

int main ()
    mpf_set_default_prec (15);
    int x=1; //loop
    mpf_t k; //series variable (should start equal to 1)
	mpf_init(k); //set equal to 0 *I THINK*
    mpf_t first_term, second_term, third_term, fourth_term, fifth_term; //terms of series broken down to guarenteed proper order of opperations (revised from v0.1)
    mpf_t pi_term;
	mpf_t final_pi;
	while(x <= 10)
		//beginning of series
    	//first_term = (1)/pow(16,k);
    	//second_term = (4)/((8*k)+1);
        //third_term = (2)/((8*k)+4);
        //fourth_term = (1)/((8*k)+5);
    	//fifth_term = (1)/((8*k)+6);
		//pi_term = second_term - third_term - fourth_term - fifth_term;
		//pi_term = pi_term * first_term;
		//end of series formula, at this point, pi_term is result of plugging value in for k
		//final_pi = final_pi + pi_term; //Adds results from series
		mpf_clear (first_term);
		mpf_clear (second_term);
		mpf_clear (third_term);
		mpf_clear (fourth_term);
		mpf_clear (fifth_term);
		mpf_clear (pi_term);
		mpf_add_ui(k,k,1); //k increases incrementally to 100,000 (should be more, but this program only does to 15 decimal places, so it is not necesary)
		x++; //x increases incrementally to satisfy while() loop, will break from loop at x<=100000
	system("CLS"); //clears command prompt/terminal window, change to (system("CLEAR"); in Mac)
	printf("Pi Calculator v0.2 By Bryan Keller\nSource code available upon request\nFormula used: Bailey Borwein Plouffe formula (BBP formula)\n");
    return 0;
As of right now, I have first_term related code turned off, simply because I'm not sure how I will go about implementing 16 to the K power using GMP.

Anyways, even with the useless 16 to the K power code commented out, the program stops responding upon first open. If anybody compiles it for themselves, you will see that through trial and error, i have figured out how to remove all errors and warnings, excluding the 16 to the K power code, which as I already mentioned, has been commented out anyways.

You'll also notice that the default precision is 15, this is simply to see if i can replicate something close to the results I was getting without GMP. After I accomplish that, I can work my way up to larger decimals.

Anyways, based on my minimal knowledge, I think the problem has to do with the program using a LOT of resources. Maybe I'm wrong, but I am declaring a lot of variables, so that's my best guess.

Thanks again for looking, and sorry for the long post, but I just want to make this as clear as possible =)