Question of C++
Can you help with editing this code? Write a program that calculates the value of e ^ x using the following equation (up to three decimal places). This program will get x and the number of secret sentences n from the input. e^x= 1 + x/1! + x^2/2! +x^3/3! +..... 👇🏻👇🏻👇🏻 #include <iostream> #include <math.h> #include <bits/stdc++.h> using namespace std; int main() { int n = 1; double x; cout << "Enter x: " ; cin >> x; cout << "Enter n: " ; cin >> n; int fact = 1; for(int i = n-1; i <=n; ++i) { fact*=i; } int e; int sum1 = 0; int sum2; while(n>0) { e = pow(x,n-1)/fact; sum2 = sum1 + exp(x); n++; } cout << fixed << setprecision(3) <<sum2; return 0; }