Home » C programs » Sum of series C programs

Here, we are going to implement a **c program that will find the sum of series 1 +1/x^1 + 1/x^2 + 1/x^3 ... + 1/x^n terms**.

Submitted by **IncludeHelp**, on March 04, 2018

#include <stdio.h> #include <math.h> int main() { int x,n,i; float sum=0; printf("Enter total number of terms: "); scanf("%d",&n); printf("Enter the value of x: "); scanf("%d",&x); for(i=1; i<=n; i++){ sum += 1+(1/pow(x,i)); } printf("Sum of the series: %f\n",sum); return 0; }

**Output**

Enter total number of terms: 5 Enter the value of x: 2 Sum of the series: 5.968750

**Solution**

Series is:1+1/x^1 + 1/x^2+ 1/x^3 ... + 1/x^nHere,x=2 n=5 1+1/2^1 + 1+1/2^2 + 1+1/2^3 + 1+1/2^4 + 1+1/2^5 1+1/2 + 1+1/4 + + 1+1/8 + 1+1/16 + 1+1/32 1+0.5 + 1+0.25 + 1+0.125 + 1+0.0625 + 1+0.03125 =5.968750

**Read more...**

Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.

Comments and Discussions

.resCodeAS1 { display: block; width: 320px; height: 50px; }
@media(min-width: 300px) { .resCodeAS1 { display: none; } }
@media(min-width: 480px) { .resCodeAS1 { display: none; } }
@media(min-width: 750px) { .resCodeAS1 { display: block; width: 336px; height: 280px; } }
(adsbygoogle = window.adsbygoogle || []).push({});

(adsbygoogle = window.adsbygoogle || []).push({});

(adsbygoogle = window.adsbygoogle || []).push({});

solved programs: » C » C++ » DS » Java » C# |

aptitude que. & ans.: » C » C++ » Java » DBMS |

interview que. & ans.: » C » Embedded C » Java » SEO » HR |

close Like other websites, this site uses cookies to deliver relevant ads based on your interest, by using our website, you acknowledge that you have read our privacy policy.