-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexp
More file actions
42 lines (36 loc) · 771 Bytes
/
exp
File metadata and controls
42 lines (36 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# ebn
// FCI – Programming 1 – 2018 - Assignment 2
// Program Name: exponential.cpp
// Last Modification Date: 1/3/2018
// Author1 and ID and Group: 20170048 G2
// Author2 and ID and Group: 20170044 G2
// Author3 and ID and Group: 20170051 G2
// Teaching Assistant: menna yousif
// Purpose:How to calculate exponential
#include <iostream>
#include<math.h>
using namespace std;
double factorial(double n)
{
double i, x = 1;
for (i = 1; i <= n; i++)
{
x *= i;
}
return x;
}
int main()
{
cout<<"Enter a number" <<endl;
double x;
cin>>x;
double term=0;
double exp=0;
for(double n=0;n<=100;n++){
term=pow(x,n)/factorial(n);
cout<<n<<")"<<term<<endl;
exp+=term;
}
cout<<"Result= "<<exp;
return 0;
}