Assignment3 (State Machine)
Assignment3 (State Machine)
h>
#include <stdint.h>
#include <string.h>
void state_01();
void state_02();
void state_03();
void state_04();
void state_05();
int main()
{
int choose;
int currentState=0;
int previousState=0;
while(1){
printf("Enter which state you want to go\n");
scanf("%d",&choose);
currentState=choose;
if(previousState==1)
{
printf("Welcome\n");
}
switch(choose)
{
case 1:
state_01();
previousState=1;
break;
case 2:
state_02();
previousState=2;
break;
case 3:
state_03();
previousState=3;
break;
case 4:
state_04();
previousState=4;
break;
case 5:
state_05();
previousState=5;
break;
}
}
}
void state_01()
{
printf("You are in state 01 of this Machine\n");
}
void state_02()
{
printf("You are in state 02 of this Machine\n");
}
void state_03()
{
printf("You are in state 03 of this Machine\n");
}
void state_04()
{
printf("You are in state 04 of this Machine\n");
}
void state_05()
{
printf("You are in state 05 of this Machine\n");
}