/* Za ucitani broj x treba u programu izracunati e**x pomocu slijedeceg reda e**x=1+x/1!+x**2/2!+... ispisati ucitani x, strvarnu vrijednost e**x, vrijednost izr pomocu sume n, te abs pogresku */ // (c) KreatoR '97 #include #include #include long float fakto(long float); //prototype void main() //sub main { int i,n,x; double e,sum=0; //declare clrscr(); //screen clear printf("Unesi broj n, te broj x "); scanf("%d %d",&n,&x); //get variables for(i=0;i<=n;i++) {sum+=pow(x,i)/fakto(i);} printf("\n\tstvarni e**x je %f",e=exp(x)); printf("\n\tdobiveni e**x je %f",sum); printf("\n\tapsolutna pogreska je %f",fabs(e-sum)); getch(); //wait for any key } long float fakto(long float racun) { //try to make this smaller!! ;) if (racun>2) {racun*=fakto(racun-1);} else if (!racun) {racun=1;} return(racun); }