#include<stdio.h>
#include<conio.h>
char getlc(void);
void main(void)
{
char chlc;
printf("Type 'a' for first selection, 'b' for second: ");
chlc=getche();
switch(chlc)
{
case'a':
printf("\nYou typed an 'a'.");
break;
case'b':
printf("\nYou typed a 'b'.");
break;
default:
printf("\nYou chose a nonexistent selection.");
}
}
char getlc(void)
{
char ch;
ch=getche();
if(ch>64&&ch<91)
ch=ch+32;
return(ch);
}
Output:
Type 'a' for first selection, 'b' for second: a
You typed an 'a'.
#include<conio.h>
char getlc(void);
void main(void)
{
char chlc;
printf("Type 'a' for first selection, 'b' for second: ");
chlc=getche();
switch(chlc)
{
case'a':
printf("\nYou typed an 'a'.");
break;
case'b':
printf("\nYou typed a 'b'.");
break;
default:
printf("\nYou chose a nonexistent selection.");
}
}
char getlc(void)
{
char ch;
ch=getche();
if(ch>64&&ch<91)
ch=ch+32;
return(ch);
}
Output:
Type 'a' for first selection, 'b' for second: a
You typed an 'a'.
Type 'a' for first selection, 'b' for second: A
You typed an 'a'.
Type 'a' for first selection, 'b' for second: c
You chose a nonexistent selection.
0 comments:
Post a Comment