[Solved] Generating random matrix in c [closed]


int main()
{
    int random[3][3];
    int i, o;

    srand(time(NULL));
    for(o = 0; o<3; o++)
        for(i = 0; i<3; i++)
            random[o][i] = rand();
    return 0;
}

That’ll do it. If you want a particular subset of data you can use the % operator on the output from rand(), for example:

rand() % 10; // generates a random number 0-9

1

solved Generating random matrix in c [closed]