Feb 26, 2007

C++ program to generate a melodious sound from PC speaker

C++ program to generate a melodious sound from PC speaker. For this purpose sound() function, delay() function and nosound() function are used. For these functions a special header file dos.h is included.
#include<iostream.h>
#include<conio.h>
#include<dos.h>
main()
{
clrscr();
for(int i=100;i<=1000;i=i+100)
{
sound(i);
delay(500); // time delay in milliseconds
nosound(); // it will stop the sound
}
getch();
}

No comments:

Post a Comment