i)Create a program that asks the user to input a number between 2 and 5. If the number given isn't between those two numbers make it so the program asks the user for a new number until it is larger than two and smaller than 5.

ii)e^x=x^0/0! + x^1/1! + x^2/2! + ...

iii)Create a program that calculates the above series until x^n/n!<=0.0001 and then print the value of x given, e^x, and the last term which was added.

I did what I was asked, but when I run the program it gave me a false result. Also it says that the last term which was added is negative! I struggled for hours to figure out where my mistake was, I even had the teacher take a look at it, but we couldn't find anything. Don't forget that you need to use the command " gcc -o ..... -lm" to compile this program. Please help me find my mistake.

#include <stdio.h> #include <math.h> int main() { int i, fact; double x,a,e,sum; printf(" \n Input a real number between 2 and 5 : "); scanf("%lf%, &x); while(x<=2 || x>=5) { printf("\n Input another real number thst fits the conditions stated above : "); scanf("%lf%, &x); } i=1; a=1.0; fact=1; e=0.0001; sum=0.0; while(a>=e) { a=pow(x,i)/fact; i++; fact=fact*i; sum=sum+a; } printf("\n x=%lf, e^x=%lf and last term which was added is a=%lf \n",x,sum,a); return 0; }