Welcome
Welcome to the forums of AntiRTFM's Absolute N00b Spoonfeed C++ Tutorials!

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, <a href="/profile.php?mode=register">join our community today</a>!

does this woek?

Ask ALL your questions here

does this woek?

Postby tsimpson on Fri Oct 23, 2009 1:08 pm

Is anyone brave enough to try out this code and see if it works for me seen as my puter don't beep please.

Code: Select all
/* Enter the value to Beep
Make a simple beep when a vlue is enetered (frequency_hrs, duration_ms)
<Theophilus Simpson>
<20-October-2009>  */

#include <iostream> //Input Output header for cout
#include <windows.h> //Windows header for beep



using namespace std; //Use standard Library

int main () //Main program begins here
{
   int Beep,time;

   cout<<"Please enter the frequency value between 440 to 659\n\n";
      cin>>Beep; //assign enter frequency of beep
   cout<<"please enter the time lengh for beep to play\n\n";
       cin>>time;  //assign entered lengh of beep
   cin.ignore();
   cin.get();
   return 0; //indicate successful end of program
tsimpson
 
Posts: 17
Joined: Sun Oct 18, 2009 7:27 pm

Re: does this woek?

Postby noobgrammer on Fri Oct 23, 2009 6:50 pm

No it didn't you didn't use the beep right I changed it a little this works

Code: Select all
    /* Enter the value to Beep
    Make a simple beep when a vlue is enetered (frequency_hrs, duration_ms)
    <Theophilus Simpson>
    <20-October-2009>  */

    #include <iostream> //Input Output header for cout
    #include <windows.h> //Windows header for beep



    using namespace std; //Use standard Library

    int main () //Main program begins here
    {
       int beep,time;

       cout<<"Please enter the frequency value between 440 to 659\n\n";
          cin>>beep; //assign enter frequency of beep
       cout<<"please enter the time lengh for beep to play\n\n";
           cin>>time;  //assign entered lengh of beep

      Beep(beep,time);

       cin.ignore();
       cin.get();
       return 0; //indicate successful end of program
   }



You don't cin the Beep() you cin the frequency and the duration and put those inside of the Beep()

Code: Select all
Beep(frequency, duration);


you mix that with Sleep() and you could write a tune. I gave you a link in your other post that explains that better
I need a compiler with a can of RAID built into it

I added a msn messenger just for programming feel free to email or add yourself to it
User avatar
noobgrammer
 
Posts: 198
Joined: Tue Aug 25, 2009 10:44 am
Location: Orlando

Re: does this woek?

Postby tsimpson on Sat Oct 24, 2009 6:43 am

Thank you ever so much. Slighty confussed by
Code: Select all
Beep(frequency, duration);
but will have to wait till tuesday to play with that. Other than that thank you again.
tsimpson
 
Posts: 17
Joined: Sun Oct 18, 2009 7:27 pm

Re: does this woek?

Postby noobgrammer on Sat Oct 24, 2009 7:03 am

It is just a function where you are passing in values

frequency is the sound so a frequency of 440 is a A. so if you put in

Code: Select all
Beep(440,1000);


you would play an A for one second. You can either hard code straight numbers into it like I just did or you can get user input and put that in with any name you want.

Code: Select all
cin>> sound;
cin>> length;

Beep(sound,length);


make sure it is a int value. also length is in milliseconds so 100 is a tenth and 1000 is a second just like using the Sleep() function.
I need a compiler with a can of RAID built into it

I added a msn messenger just for programming feel free to email or add yourself to it
User avatar
noobgrammer
 
Posts: 198
Joined: Tue Aug 25, 2009 10:44 am
Location: Orlando


Return to QA

Who is online

Users browsing this forum: No registered users and 0 guests