text: Program to find the sum of the series 1 + x + x ^ 2 + x ^ 3 + . . + x ^ n | C implementation to find the sum of series 1 + x ^ 2 + x ^ 3 + ... . + x ^ n ; Function to print the sum of the series ; First Term of series ; Loop to find the N terms of the series ; Driver Code
code: #include <math.h> NEW_LINE #include <stdio.h> NEW_LINE double sum ( int x , int n ) { double i , total = 1.0 , multi = x ; printf ( "1 ▁ " ) ; for ( i = 1 ; i < n ; i ++ ) { total = total + multi ; printf ( " % .1f ▁ " , multi ) ; multi = multi * x ; } printf ( " STRNEWLINE " ) ; return total ; } int main ( ) { int x = 2 ; int n = 5 ; printf ( " % .2f " , sum ( x , n ) ) ; return 0 ; }