Calculate the sum of G.P. series

C program to calculate the sum of G.P. without using formula.

Geometric progression (G.P.) or geometric sequence is a series of numbers in which common ratio (r) of any consecutive numbers (items) is always the same.
So, next element of the series is obtained by multiplying common ration (r) to the previous element.

Let, first term (a) of the G.P. series be 6 and common ratio (r) be 2
Then, Series would b
6, 12, 24, 48, ... and so on.

So, nth term (tn) will be calculated as follows:
t1 = a
t2 = a * r(2 - 1)
t3 = a * r(3 - 1)
...
tn = a * r(n - 1)

Program

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
	int a,n,r,sum=0;
    int i, term;

	printf("Enter the first term of G.P.\t:");
	scanf("%d",&a);
	printf("Enter the common ratio of G.P.\t:");
	scanf("%d",&r);
	printf("Enter the number of terms G.P.\t:");
	scanf("%d",&n);

	for(i=1;i<=n;i++)
		{
		term = a*pow(r,i-1);
		sum = sum + term;
		printf("Term number %d is %d\n",i,term);
		}

	printf("Sum of the G.P. is %d",sum);
	
	getch();
}

Output

Enter the first term of G.P.    :4
Enter the common ratio of G.P.  :2
Enter the number of terms G.P.  :5
Term number 1 is 4
Term number 2 is 8
Term number 3 is 16
Term number 4 is 32
Term number 5 is 64
Sum of the G.P. is 124