Code:
 char key;
while(run_time==1){

   key = getche();

   switch(key){

   case '1':
       sound(frequency 1);
       while(khbit()) 
           delay(1);
       nosound() ;

case '2':
       sound(frequency 2);
       while(khbit()) 
           delay(1);
       nosound() ;

   default:
     run_time=0;

}
Makes sense?

Greedy because the while loop has to work so fast. Having no delay would take up an entire core of cpu so the delay is important.