try this

Code:
#include <stdio.h>

int main(){
     float pi = 4, n;
     int j = 0, s = -1;
     printf("\ngive n:");
     scanf("%f",&n);getchar();
     for(float i = 3; j < n; i += 2, j++, s *= -1){
          pi += (4.0F / i) * s;
          printf("\n%d> %f",(j+1),pi);
     }
     getchar();
     return 0;
}
shabbir like this