/* Sum of GP series term by term */
#include<stdio.h>
#include<math.h>
int main()
{
float a, r, sum=0;
int n, i;
printf("Enter the values of a, r, n:\n");
scanf("%f%f%d", &a, &r, &n);
for(i=0;i<=n;i++)
{
sum=sum+a*pow(r,i);
}
printf("Sum of GP series:%f\n", sum);
return(0);
}
#include<stdio.h>
#include<math.h>
int main()
{
float a, r, sum=0;
int n, i;
printf("Enter the values of a, r, n:\n");
scanf("%f%f%d", &a, &r, &n);
for(i=0;i<=n;i++)
{
sum=sum+a*pow(r,i);
}
printf("Sum of GP series:%f\n", sum);
return(0);
}
Comments
Post a Comment