```
#include <stdio.h>
#include <math.h>
int main()
float i, x;
double fact=0, sum=0;
printf("Enter value of x as the power of e: ");
scanf("%f", &x);
printf("Enter n as the number of terms: ");
scanf("%d",&i);
for (i = 0; i < 99999; i++)
{
sum = 1 + x;
fact = fact * i;
sum = sum + pow(x, i)/(fact);
}
if (sum == sum)
printf("The value of e^%f is %lf",x,sum);
return 0;
```

## Recommended Answers

Jump to PostWhy are you asking for

`n`

then reading it into`i`

? And why are you then just ignoring it in your loop control?

## All 2 Replies

Reverend Jim
4,202
Hi, I'm Jim, one of DaniWeb's moderators.
Moderator
Featured Poster

xrjf
213
Posting Whiz
Premium Member

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.