This gives random number between hi and lo ( if 1 and 4 are given, then either 1, 2, 3 are displayed. But my question is, if 1 and 3 are given then I want to display either 1 or 3, no number between them.
For 1 and 3, but one of your test cases for rejecting the range suggestion was 1 and 4 being "given". This suggests that the numbers are unknown input from a user or stream. If you'll only ever be given two numbers then this approach is valid, but if you have an unknown amount of unknown numbers in an unknown range, it gets tedious very quickly. In fact, this is a manual version of my suggestion to collect the numbers in an array and randomly select from the array.
But is there any way I can do this within rand() ?
Not unless you have control over the source code of rand(), which is extremely unlikely. I say unlikely rather than impossible because it's possible to write your own version of the standard library and replace the one that came with your compiler. I do this myself, but it's not a trivial project.
Need some help with this Array. I am trying to get the sum of the even numbers and the sum of the odd numbers using a for each loop. I know the answers to what I am trying to achive are sum of even = 84 and the sum of ...
I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...