How to generate different sequences of numbers in C

1 Answer

0 votes
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

static const int SIZE = 5;

int main(void) {
    srand((unsigned int)time((time_t*)NULL));

    for (int i = 0; i < SIZE; i++) {
        printf("%d ", (rand() % 100) + 1);
    }
    
    printf("\n");

    for (int i = 0; i < SIZE; i++) {
        printf("%d ", (rand() % 100) + 1);
    }

    printf("\n");

    for (int i = 0; i < SIZE; i++) {
        printf("%d ", (rand() % 100) + 1);
    }

    return 0;
}




/*
run:

59 33 60 59 14
17 49 53 54 41
98 91 54 49 54

*/

 



answered Jun 18, 2022 by avibootz

Related questions

...