In this tutorial, we are going to write a **C Program to evaluate the geometric progression series 1/1-x=1+x+x ^{2}+x^{3}+...+x^{n}** in C Programming with practical program code and step-by-step full complete explanation.

## C Program to evaluate the geometric progression series.

#include<stdio.h> #include<conio.h> #define LOOP 100 #define ACCURACY 0.0001 void main() { int n; float x,term,sum; printf("Input value of x: "); scanf("%f",&x); sum=0; for(term=1, n=1; n<=LOOP; ++n) { sum+=term; if(term<=ACCURACY) goto output; term*=x; } printf("FINAL VALUE OF N IS NOT SUFFICIENT TO ACHIEVE DESIRED ACCURACY\n"); goto end; output: printf("EXIT FROM LOOP\n"); end: printf("sum=%f number of terms=%d",sum,n); }

### Output

Input value of x: .21 EXIT FROM LOOP Sum=1.265800 number of terms=7 Input value of x: .75 EXIT FROM LOOP Sum=3.999774 number of terms=34 Input value of x:.99 FINAL VALUE OF N IS NOT SUFFICIENT TO ACHIEVE DESIRED ACCURACY

## 0 Comments