How to make computer beep through C


#include
int main(void)
{
printf("\a");
return 0;
}








PROGRAM 2 :




#include /* beep1.c */
#include
#include

int main(void)
{
int i, j, speed = 2000;

printf("1 \a \n"); /* works with just stdio.h */
Sleep(1000); /* need windows.h */
/* must wait before dings or I won't get ding
I guess 'cause it's working so hard to make it: ) */

printf("2 \n");
putchar(0x07); /* works with just stdio.h */
Sleep(1000);

printf("3 \n");
Beep(2750, speed); /* need windows.h */
Sleep(1000);

printf("4 \n");
_beep(2750, speed); /* need stdlib.h */
_sleep(1000); /* need stdlib.h */


/* I get the same Beep for all of these */

for(i = 400; i <= 2000; i += 400 ) {
for(j = 400; j <= 2000; j += 400) {
printf("Beep(%d, %d) \n", i, j);
Beep(i, j);
/* Beep(200, speed); */
Sleep(1000);
}
}
return 0;
}
/*
Here's where they come from in my mingw - includes directory:
-----
winbase.h
BOOL WINAPI Beep(DWORD,DWORD);
-----
stdlib.h
/ *
* NOTE: Officially the three following functions are obsolete. The Win32 API
* functions SetErrorMode, Beep and Sleep are their replacements.
* /
_CRTIMP void __cdecl _beep (unsigned int, unsigned int);
_CRTIMP void __cdecl _seterrormode (int);
_CRTIMP void __cdecl _sleep (unsigned long);





Related Links :

No comments:

Post a Comment


If you face any Problem in viewing code such as Incomplete "For Loops" or "Incorrect greater than or smaller" than equal to signs then please collect from My Web Site CLICK HERE


More Useful Topics...

 

History Of C..

In the beginning was Charles Babbage and his Analytical Engine, a machine
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming
language.

My 1st Program...


#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n");
printf ("\t\t\t*******Pankaj *******\n");
printf ("\t\t\t********************************\n");
printf ("\t\t\t\"Life is Good...\"\n");
printf ("\t\t\t********************************");
getch ();
}

Next Step...


#include
#include

void main ()
{
clrscr ();
printf ("\n\n\n\n\n\n\n\n");
printf ("\t\t\t --------------------------- \n\n");

printf ("\t\t\t | IGCT, Info Computers, INDIA | \n\n");
printf ("\t\t\t --------------------------- ");

getch ();

}

Hits!!!