-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
23 lines (23 loc) · 775 Bytes
/
main.cpp
File metadata and controls
23 lines (23 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <cmath>
using namespace std;
int main ()
{
double num; //value input by the user
double factorial=1;
double exponontial=1; //stores the answer
cout << "enter real number to calculater the approxiamte value of e^x:";
cin >> num;
cout << "Displaying all values from x and entering into the equation" << endl;
for(int i=1;i<=100;++i)
{
exponontial += pow(num,i)/factorial; //calculation for exponential
factorial*=i+1; //updating the factorial
cout<<exponontial<<"\t";
if(i%10==0)
cout<<endl;
}
cout << "The calculated value for counter = 100 is "<<exponontial<<endl;
cout << "The Certain value is " << exp(num) << endl;
return 0;
}