training

Code I wrote during training
git clone git://git.bitsmanent.org/training
Log | Files | Refs | README

nsum.c (432B)


      1 /* Exercise 9.7 */
      2 
      3 #include <stdio.h>
      4 #include <stdlib.h>
      5 #include <time.h>
      6 
      7 #define SIZE 10
      8 
      9 int main(void)
     10 {
     11    int i, tot = 0, num[SIZE];
     12 
     13    /* srand( time(NULL) ); */
     14 
     15    /* Initialize the array */
     16    for(i = 0; i < SIZE; i++) {
     17       num[i] = 1 + rand() % 1000;
     18    }
     19 
     20    /* Print the table */
     21    for(i = 0; i < SIZE; i++) {
     22       tot += printf("%d", num[i]);
     23       printf("\t%d\n", tot);
     24    }
     25 
     26    return 0;
     27 } /* E0F main */
     28