Sound in C++

The sound exist in windows.h library in C++ program.The Beep function is used to create the sound and this function take 2 parameters. The one parameter take the frequency and the second take the time.

Source Code 

#include<iostream>
#include<windows.h>
using namespace std;
int main ()
{
top : int choice = 0;
 cout<<"\t \t \t LEP Tutorials \n \n";
 cout<<"\t \t   1.  Small Sound \n \n  ";
 cout<<"\t \t   2.   Loud Sound \n \n ";
 cout<<"\t \t   3.  Very Loud Sound \n \n  ";
 cout<<"Enter Your Choice to Play the Sound \n \n ";
 cin>>choice;
 if (choice == 1)
 {
  cout<<" Small Sound Played \n \n ";
  Beep (500,500);
 }
 if (choice == 2)
 {
  cout<<" Loud Sound Played \n \n ";
  Beep (1000,1000);
 }
 if (choice == 3)
 {
  cout<<" Very Loud Sound Played \n \n ";
  Beep (3000,3000);
 }
 else
 {
  goto top;
 } 
 }

Output of the Program

Sound in C++

Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment