The '%' operator returns the 'remaining' value: 30%4=2, because 30-4*n=2, where the value of 'n' is a round number (1,2,3..). This mains that when using a=b%c, 'a' will always be lower as 'c': you need n = rand()%10
If you want a "random" number, you should seed off of the time.
1 2 3 4 5 6 7 8 9 10 11
#include <iostream>
#include <ctime> // to use the time function
#include <cstdlib>
usingnamespace std;
int main()
{
srand(time(0));
int n= rand % 10;
cout << n;
}