Computer Science, asked by AnweshaRoy, 1 year ago

series program with while-wend loop using S=a+a^2/4+a^3/9+a^4/16....+a^n/n^2​

Answers

Answered by BushrajavediqbalKhan
1

Answer:

Explanation:

// C program to find sum of series  

// 1 + x^2/2 + x^3/3 + ....+ x^n/n  

#include <math.h>  

#include <stdio.h>  

 

// C code to print the sum  

// of the series  

double sum(int x, int n)  

{  

   double i, total = 1.0, multi = x;  

   for (i = 1; i <= n; i++) {  

       total = total + multi / i;  

       multi = multi * x;  

   }  

   return total;  

}  

 

// Driver code  

int main()  

{  

   int x = 2;  

   int n = 5;  

   printf("%.2f", sum(x, n));  

   return 0;  

}  

Similar questions