You are here

C sound program

Sound function produces the sound of a specified frequency. Used for adding music to a C program, try to use some random values in loop, vary delay and enjoy.

Declaration: void sound(unsigned frequency);

C programming code for sound (Turbo C compiler only)

#include <dos.h>

int main()
{
   int a;

   for (a = 200; a <= 1000; a = a + 20)
   {
      sound(a);
      delay(25);
   }

   nosound();

   return 0;
}

Share this