All pastes #927092 Raw Edit

Miscellany

public text v1 · immutable
·published 2008-03-04 01:00 UTC
rendered paste body
#include <stdio.h>
#include <math.h>
#define PI 3.1415927


long int factorial(int n)
{
        if (n<=1)
        return(1);
  else
        n=n*factorial(n-1);
        return(n);
 }

int main (void)
{
        int answer, x, i;
        float  z;
        double  y = 2/(sqrt(PI));
        long int factorial(int n);


        printf("Enter a number :");
        scanf("%i",&answer);
                if( answer == 0) {      //if answer is 0 the error is 0
                        printf("The error is : 0 \n \n");
                }       //if block ends
        else {
                for (i = 1; i <= 5; i = i + 2){
                        for (x = 0; x <= 4; ++x){
                z = z+ y*(pow(answer,i))/(i*factorial(x));

                }       //for block ends
                }

        printf("Error = %f \n", z);
        }

        return 0;
}