That makes no sense.
FA?
4D?
Your current random number generator might start off like that, but everyone else sees different things.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char string1[30] = "hello";
int length, myDivMod;
unsigned int myRand;
length = strlen(string1);
srand(length); // seed rand generator
for (int i = 0; i < length; ++i) {
myRand = rand(); // get random number
printf("R1=%10u(%10x) ", myRand, myRand);
myDivMod = myRand % length; // - length / 2; // get mod of random number
myRand = myRand / length; // should equal 6 with 4D random
printf("R2=%10u(%10x) ", myRand, myRand);
myRand = myRand * -1; // negate mRand by * -1
myRand = myRand + myDivMod;
printf("R3=%10u(%10x)\n", myRand, myRand);
}
return 0;
}
$ ./a.out
R1= 590011675( 232add1b) R2= 118002335( 708929f) R3=4176964961( f8f76d61)
R1= 99788765( 5f2a7dd) R2= 19957753( 13087f9) R3=4275009543( fecf7807)
R1=2131925610( 7f129a6a) R2= 426385122( 196a1ee2) R3=3868582174( e695e11e)
R1= 171864072( a3e7008) R2= 34372814( 20c7cce) R3=4260594484( fdf38334)
R1= 317159276( 12e7776c) R2= 63431855( 3c7e4af) R3=4231535442( fc381b52)