c program to find out the sum of G.P series, GP Series in C, C Program to find G.P. Series.
#include
#include
int main(){
float a,r,i,tn;
int n;
float sum=0;
printf("Enter the first number 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);
tn = a * (1 -pow(r,n-1));
printf("tn term of G.P.: %f",tn);
printf("\nSum of the G.P.: %f",sum);
return 0;
}
No comments:
Post a Comment