i want to get a random value from the set of values like{1,2,5}
how can i do that
is that possible
i m not that familiar with using random function so plz xplain a bit how to use it if it can be used in this case
i want to get a random value from the set of values like{1,2,5}
how can i do that
is that possible
i m not that familiar with using random function so plz xplain a bit how to use it if it can be used in this case
rand() will return a random number. If you want to restrict it to a set of numbers between 0 and N than use the mod % operator, such as int x = rand() % N;
hmm ohk.... so there is no possiblity to define a set of values
Well, if you have a set of values and you want to select one of them at random, then use rand() as I explained previously and use that value as the index into the array. The value of N in this case will be the amount of numbers in the array. In the example you posted replace N with 3 because the array contains 3 values.
thankQ for your valuable suggestion
:)
thanks a lot :)
It is very difficult to get the random values in C language
It is very difficult to get the random values in C language
Bullshit! How difficult is it to call rand() function?
hey dragon i wasnt familiar wid random function ...n the idea u gav with that it is very easy to do the prog thanks a lot :)
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.