Marcos

Generation

generate functionMon, 24 Apr 2023

.Realiza un programa en C que intente estimar el valor de sen(x) como la suma de los n primeros términos de la siguiente serie: x-(x^3/3!)+(x^5/5!)-(x^7/7!)+....

#include <stdio.h> #include <math.h> int main() { int n, i; float x, sine, term; printf("Enter the value of x (in degrees) \n"); scanf("%f", &x); x = x * (3.142 / 180.0); printf("Enter the value of n \n"); scanf("%d", &n); term = x; sine = term; for (i = 1; i <= n; i++) { term = -term * x * x / (2 * i * (2 * i + 1)); sine = sine + term; } printf("Sum of the sine series = %7.2f\n", sine); printf("Using Library function sin(%f) = %7.2f\n", x, sin(x)); }

Questions about programming?Chat with your personal AI assistant