summaryrefslogtreecommitdiff
path: root/linear_spaced.c
blob: d8dd3012b271502005f6819dead2b6b88710e260 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*  File: linear_spaced.c
    Generates linearly spaced atat for an array with N elements from x0 to xf*/
    
#include <stdio.h>

#define N 11

int main()
{
    double  x[N],
            x0 = 0.0,
            xf = 5.0;
    double  j = x0;
    
    int i;
    
    printf("%-4c",'c');
    /*  generate linearly spaced data for an array with N elements */
    double step = (xf - x0)/((double)N);
    for(i=0;i<N;i++)
    {
        printf(" %4d ",i);
        x[i] = j;
        j += step;
    }
    printf("\n%-4c",'c');
    for(i=0;i<N;i++)
    {
        printf(" %4.2f ",x[i]);
    }
    printf("\n");
    return 0;
}