I can not find an error. Nothing derives.
#include <iostream> #include <math.h> using namespace std; int fact(int n) { if (n < 0) { return 0; } return n ? n * fact(n - 1) : 1; } int main() { double sinus = 0; double x = 0, y = 0; double e1 = (pow(10, -4)) / 0.6; //точность вычисления for (x = 0.1; x >= 0.2; x + 0.01) { y = x + 0.74; do { int k = 0; sinus = (pow(-1, k)*(pow(y, 2 * k + 1)) / (fact(2 * k + 1))); ++k; } while (abs(sinus) >= e1); cout << sinus << endl; } return 0; }
sinuscalculation in awhileor an exit condition (I still need to remember the expansion in a row :)) - a loop occurs. Try to figure out the code yourself, compare it with the algorithm, then debug it (at least just asinusoutput at each iteration of the loop). - Yuriy Orlov