Internal Beep Program

Discussion in 'Programming General' started by agent766, Oct 29, 2008.

Internal Beep Program
  1. Unread #1 - Oct 29, 2008 at 9:04 PM
  2. agent766
    Referrals:
    0

    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);
    }
     
  3. Unread #2 - Oct 30, 2008 at 3:40 AM
  4. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

    Internal Beep Program

    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.
     
  5. Unread #3 - Oct 31, 2008 at 7:26 AM
  6. theory_
    Joined:
    Oct 3, 2008
    Posts:
    119
    Referrals:
    0
    Sythe Gold:
    0

    theory_ Active Member

    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.
     
  7. Unread #4 - Oct 31, 2008 at 6:13 PM
  8. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

    Internal Beep Program

    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.
     
  9. Unread #5 - Nov 22, 2008 at 12:38 PM
  10. Teh_Uber_Codex
    Joined:
    Nov 22, 2008
    Posts:
    75
    Referrals:
    0
    Sythe Gold:
    0

    Teh_Uber_Codex Member
    Banned

    Internal Beep Program

    Thanks SWAN.

    ~Uber
     
  11. Unread #6 - Feb 21, 2009 at 11:53 PM
  12. xedon
    Joined:
    Nov 18, 2007
    Posts:
    11
    Referrals:
    0
    Sythe Gold:
    0

    xedon Newcomer

    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);
    }

    }
     
  13. Unread #7 - Feb 25, 2009 at 6:40 AM
  14. d great one
    Joined:
    Nov 4, 2007
    Posts:
    930
    Referrals:
    2
    Sythe Gold:
    0

    d great one Apprentice

    Internal Beep Program

    very long declaration of int :D.

    You could just state

     
< Help W/ Buttons | If you need help.... >

Users viewing this thread
1 guest


 
 
Adblock breaks this site