Home » C programs » dos.h header file functions

sound() and nosound() functions of dos.h in C

sound() and nosound() functions of dos.h in C: In this article, we are going to learn about the sound in programs and how we can use them with the help of our pre-defined functions of dos.h header file?
Submitted by Manu Jemini, on March 17, 2018

Our system can create various sounds on different frequencies. The example below demonstrates it nicely of how we can use the variable ‘a’ to generate different sound.

The delay() function has been used in this function to delay for the next sound. The Second thing is the nosound() function, which simply silent the system.

The sound() is very useful as it can create very nice music with the help of programming and our user can enjoy music during working in out the program.

These two functions are from file dos.h, which should be included in the program.

dos.h - sound() function Example in C



#include <stdio.h>
//to use 'sound()', 'delay()' functions
#include <dos.h>

int main()
{
	int k;
	//loop to increment the value of a till 100.
	for ( k = 1 ; a <= 100 ; a = k++ )
	{
		//calling the function for producing 
		//the sound of value a.
		sound(a);
		//delay the sound 10 miliseconds.
		delay(10);
	}
	// function to stop the system sound.
	nosound();
	return 0;
}

dos.h - nosound() function Example in C



#include <stdio.h>
//to use 'sound()', 'delay()' functions
#include <dos.h>

int main()
{
	//calling the function for producing 
	//the sound of frequency 400.
	sound(400);

	//function to delay the sound for 
	//half of second.
	delay(500);

	//calling the function to stop the 
	//system sound.
	nosound();

	return 0;
}





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.
Learn PCB Designing: PCB DESIGNING TUTORIAL




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.