C++: for Loop With Beeps (Windows)
by matt392 in Circuits > Software
8 Views, 0 Favorites, 0 Comments
C++: for Loop With Beeps (Windows)

For loop using Beep() function in Windows:
#include <iostream>
#include <windows.h> // Need this library for Beep() function
using namespace std;
int main()
{ // start main function
int NumberOfBeeps;
int alpha;
cout << "Enter the number of beeps you would like to hear: ";
cin >> NumberOfBeeps;
for (alpha=1; alpha<=NumberOfBeeps; alpha++)
{
cout << "Beep at the frequency of 1,000 hertz for 750 milliseconds per beep.\n";
Beep(1000, 750); // Beep frequency at 1,000 hertz for 750 milliseconds
// Note the Beep() function only works on Windows!
} // end for loop
return 0;
} // end main function
Downloads
Supplies



- Code::Blocks IDE for C++
- Desktop or laptop with Windows



For loop using Beep() function in Windows:
#include <iostream>
#include <windows.h> // Need this library for Beep() function
using namespace std;
int main()
{ // start main function
int NumberOfBeeps;
int alpha;
cout << "Enter the number of beeps you would like to hear: ";
cin >> NumberOfBeeps;
for (alpha=1; alpha<=NumberOfBeeps; alpha++)
{
cout << "Beep at the frequency of 1,000 hertz for 750 milliseconds per beep.\n";
Beep(1000, 750); // Beep frequency at 1,000 hertz for 750 milliseconds
// Note the Beep() function only works on Windows!
} // end for loop
return 0;
} // end main function