Monday 18 July 2011

Write a c program to find out the sum of infinite G.P. series


Sum
of infinite GP series in c programming language



#include



int 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

No comments:

Post a Comment