Silentearth
Femtopat
- Katılım
- 9 Eylül 2023
- Mesajlar
- 7
Daha fazla
- Cinsiyet
- Kadın
Hatayı nerede yapıyorum?
Soru: Write a C program to display the sum of the series:
Kod:
Soru: Write a C program to display the sum of the series:
1 + 𝑥 +𝑥^2/2! +𝑥^3/3! +x^4/4! + ⋯𝑥^n/n!
Kod:
C:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int x, n, i, j, sum =1;
float fac = 1, result =1, f;
printf("enter value of x: ");
scanf("%d", &x);
printf("enter value of n: ");
scanf("%d", &n);
for(i=0; i < n ; i++)
sum= sum * x;
for(j = 1; j <= n; j++)
{
fac = fac * j;
f = sum / fac;
result = result + f;
}
printf("The result is : %d", result);
return 0;
}
Son düzenleyen: Moderatör: