getting a random letter in c 2b 2b

Solutions on MaxInterview for getting a random letter in c 2b 2b by the best coders in the world

showing results for - "getting a random letter in c 2b 2b"
Ousmane
12 Nov 2016
1char cch = 'a' + rand()%26;
Andreas
22 Aug 2018
1    char c;
2    int r;
3
4    srand (time(NULL));    // initialize the random number generator
5    for (i=0; i<num; i++)
6    {    r = rand() % 26;   // generate a random number
7          c = 'a' + r;            // Convert to a character from a-z
8          cout << c;
9    }