Beeping the Speaker - C

Beeping Speaker

Snippet Code


  
Rate this page :
  [ 0 votes]

#include <dos.h> #include <stdio.h> #include <stdlib.h> int menu(void); main() { while(1) { /*get selection and execute the relevant statement*/ switch(menu()) { case 1: { puts(<q>sound the speaker 1n</q>); sound(2000); sleep(2); nosound(); break; } case 2: { puts(<q>sound that speaker 2n</q>); sound(4000); sleep(2); nosound(); break; } case 3: { puts(<q>You are quittingn</q>); exit(0); break; } default: { puts(<q>Invalid menu choicen</q>); break; } } } return 0; } /*menu function*/ int menu(void) { int reply; /*display menu options*/ puts(<q>Enter 1 for beep 1.n</q>); puts(<q>Enter 2 for beep 2.n</q>); puts(<q>Enter 3 to quit.n</q>); /*scan for user entry*/ scanf(<q>%d</q>, ampreply); return reply; }

Tags


Ask Questions

Ask Question