// con1.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include using namespace std; int main() { double x; int i = 1, maxNumTerms = 1; double powerOfX = 1, f_x = 0.0; int factorial = 1, sign = 1; //cin >> x >> maxNumTerms; x = .2; maxNumTerms = 4; powerOfX = x; // first term f_x = x; // I know what I'm doing 3 b/c for (i = 3; i < 2 * maxNumTerms; i += 2) { powerOfX *= x * x; factorial *= i * (i - 1); sign = -sign; double ithTerm = sign * powerOfX / factorial; f_x += ithTerm; } // cout f_x return 0; }