#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; Kepler123 0 Newbie Poster
Recommended Answers
Jump to Post— Reverend Jim 6,665Why are you asking for
nthen reading it intoi? And why are you then just ignoring it in your loop control?
All 2 Replies
Reverend Jim 6,665 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
xrjf 247 Posting Whiz
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.