By the way, rand() returns a new random number each time it is called, so
Code:
cout <<rand () %101 << "\n";
would not be expected to display r. If you want it to display r, you have to tell it to display r.