#include main() { double pi; int K; int k; printf("Enter the degree of approximation: "); scanf("%d", &K); for (k = 0, pi = 0.0; k <= K; k++) { if (k % 2 == 0) /* k is even */ pi = pi + 4 / (2 * k + 1); else /* k is odd */ pi = pi - 4 / (2 * k + 1); } printf("The value of pi is: %11.9f\n", pi); }