All pastes #927262 Raw Edit

Someone

public text v1 · immutable
·published 2008-03-04 03:51 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, error;
        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){
                                if ( x % 2 = 1) {
                                        answer = answer * -1;
                                }
                                else{
                                        answer = answer * -1;
                        z = z + (pow(answer,i))/(i*factorial(x));
                                        //if block ends
                                }       //else block ends
                        error = y * z;

                }       //for block ends
                }