/*
 * Illustrate conditionals in C
 */

#include <stdio.h>

#define N 100

double fun (double x) {
    double f;

    if (x <= 0.) {
        f = 0.;
    } else if (x < 1.) {
        f = x;
    } else {
        f = 1./x;
    }

    return(f);
}

int main(void) {
    double x, xl = -1., xr = 2., step;
    int i;

    step = (xr - xl)/(N-1);
    x = xl;

    for (i = 0; i < N; i++) {
        printf("% f     %f\n", x, fun(x));
        x += step;
    }

    return(0);
}