In this article, we will show you, How to Write a C Program to find Sum of Geometric Progression Series (G.P. Series) using Math Formula, and without using Mathematical formula.

## Geometric Progression Series

Geometric Series is a sequence of terms in which next element is obtained by multiplying common ration to previous element. Or,

G.P. Series is a series of numbers in which common ratio of any consecutive numbers (items) is always a same.

The mathematical formula behind this Sum of G.P Series

Sn = a(r^{n}) / (1- r)

Tn = ar^{(n-1)}

## C Program to find Sum of Geometric Progression Series Example

This C Program allows the user to enter first value, total number of items in a series, and the common ratio. Next, it will find sum of Geometric Progression Series. Here, we used For Loop to display the G.P series, which is optional.

/* C Program to find Sum of Geometric Progression Series */ #include <stdio.h> #include<math.h> int main() { int a, n, r; float tn, sum = 0; printf(" Please Enter First Number of an G.P Series: "); scanf("%d", &a); printf(" Please Enter the Total Numbers in this G.P Series: "); scanf("%d", &n); printf(" Please Enter the Common Ratio: "); scanf("%d", &r); sum = (a * (1 - pow(r, n ))) / (1- r); tn = a * (pow(r, n - 1)); printf("\n The Sum of Geometric Progression Series = %.2f", sum); printf("\n The tn Term of Geometric Progression Series = %.2f \n", tn); return 0; }

**OUTPUT**

## C Program to find Sum of Geometric Progression Series without Math Formula

In this Program, we are not using any Mathematical formula.

/* C Program to find Sum of Geometric Progression Series */ #include <stdio.h> #include<math.h> int main() { int a, n, r, value, i; float sum = 0; printf(" Please Enter First Number of an G.P Series: "); scanf("%d", &a); printf(" Please Enter the Total Numbers in this G.P Series: "); scanf("%d", &n); printf(" Please Enter the Common Ratio: "); scanf("%d", &r); value = a; printf("G.P Series : "); for(i = 0; i < n; i++) { printf("%d ", value); sum = sum + value; value = value * r; } printf("\n The Sum of Geometric Progression Series = %f\n", sum); return 0; }

**OUTPUT**

## C Program to find Sum of Geometric Progression Series using Functions

This Program is same as above. However, we separated the logic using Functions

/* C Program to find Sum of Geometric Progression Series */ #include <stdio.h> #include<math.h> int sumofGP(int a, int n, int r) { int sum = (a * (1 - pow(r, n))) / (1- r); return sum; } int main() { int a, n, r; float sum = 0; printf(" Please Enter First Number of an G.P Series: "); scanf("%d", &a); printf(" Please Enter the Total Numbers in this G.P Series: "); scanf("%d", &n); printf(" Please Enter the Common Ratio: "); scanf("%d", &r); sum = sumofGP(a, n, r); printf("\n The Sum of Geometric Progression Series = %f\n", sum); return 0; }

**OUTPUT**