Countdown Alarm
Posted: Fri May 07, 2010 2:15 am
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);
}}
}