This repository has been archived on 2023-10-26. You can view files and clone it, but cannot push or open issues or pull requests.
VSMechatronics/Lectures/LC8/Switch2/switch_2.c

35 lines
593 B
C
Raw Normal View History

2022-04-07 15:58:01 +00:00
/* Chapter 8 */
/* Example of a simple if statements */
#include <stdio.h> /* Standard include files */
#include <stdlib.h>
#include <conio.h> /* Required for getch() */
int main( void )
{
char c; /* Define an char */
c = getch(); /* Get value */
2022-04-07 15:58:01 +00:00
switch (c) /* Start of switch */
{
case '1':
printf("Hi"); /* Case 1 */
break;
case '2':
printf("Bye"); /* Case 2 */
break;
default :
printf("Err"); /* Default */
break;
}
return 0;
}