Why in shuffle function rand() % (i+1)

in shuffle function at last 5-6 min of video, why it is rand() % (i+1) and not just %i … pls explain with proper ex

@Rahulkr102 hey rahul see this geeks for geeks article this thing clear your doubt

in this article the ith element is included whereas at 15.15 bhaiya said , if at some index i of an array then before that i , there are (i+1) elements but there are i elements before that index i. (bhaiya cleared said before that and index i is not included)

this is written in article–>> The idea is to start from the last element, swap it with a randomly selected element from the whole array (including last).

koi bolega kch TA ?

@Yashwardhan_Gautam hello bhaiya I need some suggestion from your side

@jaiskid
here rand() function returns any arbitrary number (read more about it here) and taking the mod of any number with (i+1) will return a remainder between 0 to i.
Hope this helps.

@Yashwardhan_Gautam thanks bhaiya

Moreover,
For further issues you can put it in doubt section.
It’ll be easier and faster for me to reply there and someother TA will reply in case I’m not available.

@Yashwardhan_Gautam okay bhaiya

It’ll be great @jaiskid,
If you mark the previous two doubts resolved and give rating if you wish to.
PS: you can call me just Yashwardhan :smile:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.