Write a program using following equation: ⁡((x-1)/x)+1/2⁡((x-1)/x)^2 +1/2 ((x-1)/x)^3+⋯ +1/2⁡((x-1)/x)^n

Write a program using following equation.



Program:
#include<stdio.h>
#include<math.h>
main()
{
int n, i;
float x,sum=0,y;

printf("Enter N = ");
scanf("%d", &n);

printf("Enter X = ");
scanf("%f", &x);
y=(x-1)/x;
for(i=2; i<=n; i++)
{
sum=sum+(pow(y,i)*.5);
}
printf("Sum=%f", sum+y);
}

Loading
Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Flying Twitter Bird Widget By ICT Sparkle