Please, be specific about your question
What language are we talking about (C I'd assume from your tag)?
Is there any error message or warning?
Are you running it on OnlineGDB or on your own (Mac) computer? (If on online GDB, it is rather irrelevant that you have a Mac.)
The best course of action would be to share your code that does not work. You can link your entire project via the SHARE button (3 to the right from the RUN button).
C language specific
If you're talking about the sleep() in C, then the C standard does not have a sleep() function. Individual distributions have their own implementation. Check this out.
Probably all you're missing is the following include:
#include <unistd.h>