I am trying to generate a random in the range of the array size, and print the random element from the array then return the index of such element. This is what I have so far. The code isn't working. Can anybody please help me?
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
srand ( time(NULL) );
int myArray[11] = { 4,8,2,5,9,1,7,10,43,23,3 };
int randomIndex = rand();
int randomValue = myArray[randomIndex];
printf("Reference: %d\n", randomValue);