Example ouput:

3.14 2345 times

3.141 xxxx times

3.1415 xxxx times

Any help would be greatly appreciated. I don't need anyone to actually do the code, just give me a hint at what I am doing wrong. My logic is obviously off. I will get a response, but all of the amount for the counters match exactly on all values.

Here is what I have so far:

// // main.c // Homework4.26 // // Created by Christopher Mood on 10/13/13. // Copyright (c) 2013 Christopher Mood. All rights reserved. // #include <stdio.h> #include <stdlib.h> int main() { int i1, i2, i3, i4; int counter1 = 0; int counter2 = 0; int counter3 = 0; int counter4 = 0; float pi1, pi2, pi3, pi4 = 4.0; printf(" \t\t\t\t Calculating the Value of π \n\n"); printf("Number\tIterations\n\n"); for ( i1 = 3; i1 <= 100000; i1 += 2) { if ( counter1 % 2 == 0 ) pi1 -= 4.0 / (double)i1; else { pi1 += (4.0 / (double)i1); counter1++; put ((pi1 = 3.14)); printf("%f\t%d\n\n",pi1,counter1); for ( i2 = 3; i2 <= 100000; i2 += 2) { if ( counter2 % 2 == 0 ) pi2 -= 4.0 / (double)i2; else pi2 += 4.0 / (double)i2; counter2++; for ( i3 = 3; i3 <= 100000; i3 += 2) { if ( counter3 % 2 == 0 ) pi3 -= 4.0 / (double)i3; else pi3 += (4.0 / (double)i3); counter3++; for ( i4 = 3; i4 <= 100000; i4 += 2) { if ( counter4 % 2 == 0 ) pi4 -= 4.0 / (double)i4; else pi4 += 4.0 / (double)i4; counter4++; if ((pi1 = 3.14)){ printf("%f\t%d\n\n",pi1,counter1); } if ((pi2 = 3.141)){ printf("%f\t%d\n\n",pi2,counter2); } if ((pi3 = 3.1415)){ printf("%f\t%d\n\n",pi3,counter3); } if ((pi4 = 3.14159)){ printf("%f\t%d\n\n",pi4,counter4); } } } } } } }