The following flow chart represents reading a switch and dep
The following flow chart represents reading a switch and depending upon the result performing some action. Figure 5. Code to test switch. Develop a draft program to perform the actions/implement the flow chart of figure 5.
Solution
#include <stdio.h>
int main() {
/* local variable definition*/
char port = \'B\';
switch(port){
Case \'A\':
printf(\"switch pressed!\ \");
break;
Case \'B\':
Case \'C\':
printf(\"switch is off\ \");
break;
default:
printf(\"innvalid port\ \");
}
printf(\"Your port is %c\ \",port);
return 0;
}
