Question:Sum of GP series in c programming language 

Answer 
#include<stdio.h>
#include<math.h>

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;
}
Sample output: Enter the first number of the G.P. series: 1 Enter the total numbers in the G.P. series: 5 Enter the common ratio of G.P. series: 2 tn term of G.P. : 16.000000 Sum of the G.P. : 63.000000 

+ Report
Total Preview: 535
Sum of GP series in c programming language
Copyright © 2025. Powered by Intellect Software Ltd