I've made a small countdown and every 5 seconds it should make a beep sound but im not sure how to do this without an extra delay. How can i avoid this? I cant find anything that answers this specific question.
#include <iostream>
#include <Windows.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    while (N > 0)
    {
        Sleep(1000); 
        cout << N << endl;
        if(N%5==0) 
        {
            cout << "beep" << endl;
            Beep(1000, 500);
        }
        N--;
    }
}
 
     
     
    