Use of Sound and delay function in C

sound()is used to make a sound in a program. textattr() method is used for colourful characters.We can display Colourful Characters in TextMode and play sounds of random frequencies.

 

#include<stdio.h>

#include<dos.h>

#include<conio.h>

#include<stdlib.h>

void main()

{

   int countt=50;

   clrscr();

   while(countt--)

   {

                sound(5*random(100));

                delay(80);

                nosound();

                textattr(random(20)+'a'+BLINK);

                cprintf("**");

                cprintf("XCnotes.com");

               textcolor(WHITE);

                cprintf("**");//white color stars

   }

       getch();

}

 Sound function in C

Explanation….

In above example we use nosound() means the function that end the sound in the program.

Delay() function is used to increase or decrease the timing of the sound in the program.Here delay() is used to wait 80 millisecond and nosound() remove sound for each iteration.If we don’t use this function(nosound()), noise(sound) will continue until shut down the PC.

Sound() takes a parameter(sound(5*random(100)) which indicates frequency level of sound.