programming-examples/c/Series_Programs/C Program to find Sum of infinite GP series.c
2019-11-15 12:59:38 +01:00

16 lines
386 B
C

/*Sum of infinite GP series.*/
#include<stdio.h>
main()
{
float a,r;
float sum=0;
printf("Enter the first number of the G.P. series: ");
scanf("%f",&a);
printf("Enter the common ratio of G.P. series: ");
scanf("%f",&r);
if(1 > r)
sum = a/(1-r);
else
sum = a/(r-1);
printf("\nSum of the infinite G.P. series: %f",sum);
}