0% found this document useful (0 votes)
92 views2 pages

Alarm and Buzzer Code

This C++ program acts as an alarm or buzzer by playing a sound after a set amount of time. It allows the user to input a number of minutes and then counts down the time on screen. When the time reaches zero, it plays a sound for 500 milliseconds before stopping. The user can also stop the timer early by pressing a key.

Uploaded by

Hafza Ghafoor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views2 pages

Alarm and Buzzer Code

This C++ program acts as an alarm or buzzer by playing a sound after a set amount of time. It allows the user to input a number of minutes and then counts down the time on screen. When the time reaches zero, it plays a sound for 500 milliseconds before stopping. The user can also stop the timer early by pressing a key.

Uploaded by

Hafza Ghafoor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Alarm and buzzer (C++ Program)

/*

This software is the sound based software on c++ which is use blow sounds after a
particular time or when the user press any key , therefore it is use as the buzzer
in contests. This is the link of the alarm developed by me !

https://www.youtube.com/watch?v=r198d7G3ddU
*/

#include<dos.h>
#include<conio.h>
#include<iostream.h>
#include<time.h>
#include<process.h>
void d()
{
cout<<"nntttPress any key to stop the timer.";
cout<<"nnnnnnnntttt ALARM SYSTEM";
cout<<"ntttt==============";

}
void main()
{
loop:
clrscr();
char ans;
float a;
d();
cout<<"nntttenter the value to set the alarm in minutes:";
cin>>a;
float f,s;
f=clock();
for(int i=(a*60),b=60;!(kbhit());i--,b--)
{
cout<<"nnttttTime remaind:"<<i/60<<":"<<b;
delay(1000);
if(i==0)
{
sound(500);
delay(500);
nosound();
break;
}
if(b==0)
{
b=60;
}
clrscr();
d();
}
s=clock()-f;
sound(500);
delay(1000);
nosound();

cout<<"nnnttttTIME OVER!";
cout<<"nntttYou buzz after:"<<(a*60)-i<<" seconds";
cout<<"nntttDo you want to use it again?(y/n)";
cin>>ans;
if(ans=='y'||ans=='Y')
{
goto loop;
}
else
{
exit(0);
}
getch();
}

You might also like