This C Program calculates the sum of G.P series. This program is used to find the sum of the geometric progression series. Here G.P stands for geometric progression. A geometric progression, or GP, is a sequence where each new term after the ?rst is obtained by multiplying the preceding term by a constant r, called the common ratio. The formula used in this program are Tn = a * (r ^ (n – 1)). where Tn is the last term of a finite sequence. Sn = a(1 – r ^ n + 1) / (1 – r) where Sn is the sum of n terms.

Here is source code of the C Program to Find the the sum of G.P series. The C program is successfully compiled and run on a Linux system. The program output is also shown below.

`/*`

`* C Program to Find the Sum of G.P Series`

`*/`

`#include <stdio.h>`

`#include <math.h>`

int main()

`{`

float a, r, i, last_term, sum = 0;

int n;

printf("Enter the first term of the G.P. series: ");

scanf("%f", &a);

printf("Enter the total numbers in the G.P. series: ");

scanf("%d", &n);

printf("Enter the common ratio of G.P. series: ");

scanf("%f", &r);

sum = (a *(1 - pow(r, n + 1))) / (1 - r);

last_term = a * pow(r, n - 1);

printf("last_term term of G.P.: %f", last_term);

printf("\n Sum of the G.P.: %f", sum);

return 0;

`}`

Output: $ cc pgm22.c -lm $ a.out Enter the first term of the G.P. series: 3 Enter the total numbers in the G.P. series: 7 Enter the common ratio of G.P. series: 2 last_term term of G.P.: 192.000000 Sum of the G.P.: 765.000000

**Sanfoundry Global Education & Learning Series – 1000 C Programs.**

Here’s the list of Best Reference Books in C Programming, Data-Structures and Algorithms

If you wish to look at other example programs on Mathematical Functions, go to C Programming Examples on Mathematical Functions. If you wish to look at programming examples on all topics, go to C Programming Examples.