fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #define STEP 0.1
  5. #define NUM 10
  6. #define ARRAY_SIZE 100
  7.  
  8. int main() {
  9.  
  10. double array[ARRAY_SIZE]; // declare an array of 100 elements
  11.  
  12. int i; // a counter in order to fill values in it
  13.  
  14. for(i = 0; i < ARRAY_SIZE; i++) {
  15. if(i == 0) { // if we are on the first element, set it to NUM
  16. array[i] = NUM;
  17. } else { // otherwise make the sum
  18. array[i] = array[i-1] + STEP;
  19. }
  20.  
  21. }
  22.  
  23.  
  24. // now print the whole array
  25. for(i = 0; i < ARRAY_SIZE; i++) {
  26. printf("%g\n", array[i]); // %g format string to print double values
  27. }
  28. return EXIT_SUCCESS;
  29.  
  30. }
  31.  
Success #stdin #stdout 0s 2248KB
stdin
Standard input is empty
stdout
10
10.1
10.2
10.3
10.4
10.5
10.6
10.7
10.8
10.9
11
11.1
11.2
11.3
11.4
11.5
11.6
11.7
11.8
11.9
12
12.1
12.2
12.3
12.4
12.5
12.6
12.7
12.8
12.9
13
13.1
13.2
13.3
13.4
13.5
13.6
13.7
13.8
13.9
14
14.1
14.2
14.3
14.4
14.5
14.6
14.7
14.8
14.9
15
15.1
15.2
15.3
15.4
15.5
15.6
15.7
15.8
15.9
16
16.1
16.2
16.3
16.4
16.5
16.6
16.7
16.8
16.9
17
17.1
17.2
17.3
17.4
17.5
17.6
17.7
17.8
17.9
18
18.1
18.2
18.3
18.4
18.5
18.6
18.7
18.8
18.9
19
19.1
19.2
19.3
19.4
19.5
19.6
19.7
19.8
19.9