• Log in or sign up for an account here: https://www.sythe.org/login

Internal Beep Program

  • Thread starter Thread starter agent766
  • Start date Start date
A

agent766

Guest
Internal Beep Program
Here's basically a simple program I made to REALLY annoy my friends. 10kHz is awesome at annoying people ;)

Code:
#include <iostream>
#include <windows.h>

int main() {
do {
     cout << "Frequency: ";
     cin >> x;
     cout << endl << "Duration: ";
     cin >> y;

     Beep(x,y);
     System("CLS");
} while(true);
}
 
Internal Beep Program
Here's basically a simple program I made to REALLY annoy my friends. 10kHz is awesome at annoying people ;)

Code:
#include <iostream>
#include <windows.h>

int main() {
do {
     cout << "Frequency: ";
     cin >> x;
     cout << endl << "Duration: ";
     cin >> y;

     Beep(x,y);
     System("CLS");
} while(true);
}
Mind telling me where you declared variables 'x' and 'y'?

Also, you could just use escape characters to achieve the same thing.

Code:
printf("\a");
omits a system beep.
 
Internal Beep Program
By convention, his main should return something too. agent766, should also use k&r style scoping. A better control flow statement might have just been using a while statement(less typing). And variable x, and y are not declared.
 
Internal Beep Program
By convention, his main should return something too. agent766, should also use k&r style scoping. A better control flow statement might have just been using a while statement(less typing). And variable x, and y are not declared.
Ehh, do-while has a subtle difference though. It actually executes once beforehand regardless of the condition set in the while loop. But I agree for the most part.
 
Internal Beep Program
Try this;

#include <iostream>
#include <windows.h>

using namespace std;

int i;
int freqa;
int lengtha;
int lengtht;
int waita;
int waitt;
int timesa;




int main() {

cout << "How long would you like it to play for in seconds: ";
cin >> lengtht;
cout << "What frequency would you like to play at (about 20-200): ";
cin >> freqa;
cout << "How many times would you like this to be played: ";
cin >> timesa;
cout << "How long should we wait in between each beep in seconds: ";
cin >> waitt;

lengtha = lengtht*1000;
waita = waitt*1000;
for(i= 0; i < timesa; i++) {
Beep(freqa,lengtha);
Sleep(waita);
}

}
 
Internal Beep Program
very long declaration of int :D.

You could just state

int i,freqa,lengtha,lengtht,waita,waitt,timesa;
 
Runescape Gamblingrunescape gambling
Back
Top