#include <stdio.h>
int main()
{
double term = 1.0;
double sum = 1.0;
int n = 0;
while (term >= 0.0000001)
{
n++;
term = term/n;
sum = sum + term;
}
printf("\n Approximate value of e is: %lf ",sum);
getch();
return 0;
}
Approximate value of e is: 2.718282
First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.
Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.