Locker codes at the pool must be exactly 4 characters, all digits. Write valid_code(code): return true if it fits, otherwise false (an empty string is false too).
valid_code("2580")→Truevalid_code("12a4")→Falsebool valid_code(const char *code)#include <stdbool.h>
#include <string.h>
bool valid_code(const char *code) {
// your code here: if the length is not 4, return false
for (int i = 0; code[i] != '\0'; i++) {
// your code here: if this character is not a digit, return false
}
return true;
}
Run tries the examples. When they look right, Submit.