Countdown Alarm

All tutorials created in C++ to be posted in here.
1 post Page 1 of 1
Contributors
User avatar
wrighty1986
VIP - Donator
VIP - Donator
Posts: 119
Joined: Sat Sep 12, 2009 11:55 am

Countdown Alarm
wrighty1986
I was bored so I just slapped this together in three minutes. It's probably only useful to the people who never knew about the Beep function, lol. The code is self explanatory.
Code: Select all
#include <iostream>
#include <windows.h>

using std::cout;
using std::cin;

int main()
{
while(1){
    
    int dwn = 10;       // Countdown time
    int alrm = 5;       // Alarm Time
    int hrtz = 1500;    // Frequency
    
    cout << "\nHow long would you like to count down?\nSeconds: ";
    cin >> dwn;
    
    cout << "\nHow long would you like the alarm to sound?\nSeconds: ";
    cin >> alrm;
    
    cout << "\nWhat frequency of hertz? (300 - 5000 is recommended)\nFrequency: ";
    cin >> hrtz;

    while (dwn > 0)
    {
        cout << dwn << " seconds left.\n";
        dwn--;
        Sleep(1000);
    }
    
    while (alrm > 0)
    {
        alrm--;
        Beep(hrtz,500);
        Sleep(500);
    }}
}
Back Aegean sorry not been on i.v just been moving.
1 post Page 1 of 1
Return to “C++ Tutorials”