I have to make an array containing 25 random numbers using a function to define the random numbers but keep getting it to either display only one number at a time (instead of all of them cell by cell) or simply displaying incorrectly i.e. 0. Here is what I have so far.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int get_value (int t);
int main()
{
srand(time(NULL));
int temp[25], n;
for(n=0; n<25; n++)
temp[t] = get_value(n);
printf("value at cell %d is %d \n", n, temp[25]);
return 0;
}
//function get_value()
//needs to return rand # <-> 60 and 100 seed rand
//use rand %40+60 to ensure value is <-> 60 and 100
int get_value (int t)
{
return rand() %(40)+60;
}
Aucun commentaire:
Enregistrer un commentaire