Tuesday, 3 February 2015

Security Alarm System in C++

Structure of the Problem Requirements 

This is small and interesting console application program for beginners.  The Alarm system consist of different tones which rings differently at different situations. The alarm system contains  Police security alarm, Firebargade security alarm and earthquake security alarm. We also mentions all these alarms with different colors to identify them accurately. For this security alarm system we used beep function. Beep function take two parameters one is frequency hertz and the second is time.

Source Code

#include <iostream> 
#include <windows.h> // WinApi header
using namespace std;
int main()
{
int sitution =0;
HANDLE h = GetStdHandle ( STD_OUTPUT_HANDLE );
SetConsoleTextAttribute(h,FOREGROUND_GREEN | FOREGROUND_INTENSITY);
top: cout<<endl<<endl;
cout<<"\t \t \t LEP SECURITY SYSTEM \n \n \n ";
SetConsoleTextAttribute(h,FOREGROUND_RED | FOREGROUND_INTENSITY);
cout<<" \t \t 1. POLICE \n \n ";
SetConsoleTextAttribute(h,FOREGROUND_BLUE | FOREGROUND_INTENSITY);
cout<<" \t \t 2. Fire Bargade \n \n ";
SetConsoleTextAttribute(h,FOREGROUND_GREEN | FOREGROUND_INTENSITY);
cout<<" \t \t 3. Earthquake \n \n ";
cout<<"Press The Button for Help \n \n ";
cin>>sitution;
if (sitution ==1)
{
for (int i =0; i <20;i++)
{
Beep(1000,400);
SetConsoleTextAttribute(h,FOREGROUND_RED | FOREGROUND_INTENSITY);
cout<<" Plz Help Us \t ";
}
goto top;
}
if (sitution ==2)
{
for (int i =0; i <20;i++)
{
Beep(1000,1400);
SetConsoleTextAttribute(h,FOREGROUND_BLUE | FOREGROUND_INTENSITY);
cout<<" Fire ! Leave up \t ";
}
goto top;
}
if (sitution ==3)
{
for (int i =0; i <20;i++)
{
Beep(1000,3000);
cout<<"Earthquake Aftershocks \t ";
}
} 
}

Output of the Program

Security Alarm System in C++

Share it Please
asad

About Author!

Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.

0 comments:

Post a Comment