According to the task, it was necessary to find the sum of the series ((-1) ^ (n-1) x ^ (2n-1)) / ((4 ^ 2) (2n-1) That’s how it happened. But for k = 2 and 3 and x = 2 and 3 the sum of the series is 0. Could you look and say if something is wrong somewhere?
#include <conio> #include <iostream> #include <cmath> using namespace std; int main() { long Sum=0; double n=1; int k; double x; char answer; answer = 'y'; while (answer =='y') { cout << "vvedite k : "; cin >> k; cout << "vvedite x : "; cin >> x; for (Sum=0 , n=1 ; n <= k ; n++ ) { Sum +=( pow ( -1.0 , n-1 )*pow ( x , 2.0*n-1))/ (pow ( 4.0 , n) *(2.0*n-1)); } cout << "Summa = " << Sum << endl; cout << "Pos4itat' ewe raz? y/n\n"; cin >> answer; } getch(); return 0; }