In C, you generate a random number (rand()) then take the modulo 4 to have it between 0 and 3.
#include <stdio.h> #include <stdlib.h> #include <time.h> int main() { srand(time(NULL)); printf("Random number: %d\n", rand() % 4); return 0; }
First we take a variable integer and after that we provide a program to show that variable is under0-3or not
And for this we use conditional operator