Untitled
unknown
plain_text
4 years ago
640 B
4
Indexable
//Calcular la siguiente serie: // S=x^1/1-〖x^2/2+x^3/3- ......+/-x^n/n.〗^ #include <iostream> #include <math.h> using namespace std; int main() { int cant = 0, N = 0; float x = 0, prod = 0; cout << "Ingrese el valor de N: "; cin >> N; cout << "Ingrese el valor de x: "; cin >> x; while (cant < N) { cant = cant + 1; if (cant % 2 == 0) { prod = prod - (pow(x, cant) / cant); } else { prod = prod + (pow(x, cant) / cant); } } cout << "La Suma total es: " << prod << endl; return 0; }
Editor is loading...