> Switch Programs ~ Online tutorial

Switch Programs



Switch Programs


#include <stdio.h>

#define CODE 0


main ()

{ short digit;

printf ("Enter any digit in the range 0..9");

scanf ("%h",&digit);

if ((digit < 0) || (digit > 9))
{
printf ("Number was not in range 0..9");
return (CODE);
}

printf ("The Morse code of that digit is ");
Morse (digit);
}

/************************************************/

Morse (digit) /* print out Morse code */

short digit;

{
switch (digit)
{
case 0 : printf ("-----");
break;
case 1 : printf (".----");
break;
case 2 : printf ("..---");
break;
case 3 : printf ("...--");
break;
case 4 : printf ("....-");
break;
case 5 : printf (".....");
break;
case 6 : printf ("-....");
break;
case 7 : printf ("--...");
break;
case 8 : printf ("---..");
break;
case 9 : printf ("----.");
}
}



Please Give Us Your 1 Minute In Sharing This Post!
Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Powered By: BloggerYard.Com

0 comments: