Q:

How to generate random characters from only 'A', 'B', 'S' and 'Z' in C?

This code generates random characters from 'A' to 'Z' but I need to generate random characters from only 'A', 'B', 'S' and 'Z' characters. Please help.
int main (void)
{
    srand(time(NULL));
    char random;

    random = (rand() % 26) + 'A';

    printf ("Random: %c\n", random);

    return 0;
}

A:

Since a string literal, e.g. "ABSZ" can be used like an array of char, you can choose a random character from a set of allowed characters with code like this
random = "ABSZ"[rand()%4];

