Project 2 - Implement the Code for controlling the retraction and extension of Airplane’s landing gear
#include
#include
/* variables */
int take_f_state=0;
int lan_f_state=0;
int f_hight=250;
int f_wheel=1;
char name_1[]="take_off";
char name_2[]="landing";
/*functon prototype*/
void take__off();
void landing();
int main()
{
char pro[10];// local variable
printf("enter the process :");
scanf("%s",pro);// get input from user
if((strcmp(pro,name_1))==0)// check the condition
{
while (1)// rut until the process is end
{
take__off();
if(take_f_state==5)// check the condition
{
take_f_state=0;
break;
}
}
}
if((strcmp(pro,name_2))==0)// check the condition
{
while (1)// rut until the process is end
{
landing();
if(lan_f_state==5)// check the condition
{
lan_f_state=0;
break;
}
}
}
}
void landing()// function defination
{
switch (lan_f_state)
{
case 0:
printf("extended process start..,\n");// first state
lan_f_state=1;
break;
case 1:
if(f_hight>200)// check the hight
{
printf("proper hight is reached \n");
lan_f_state=2;
}
else// else wait for hight is reached
{
printf("waiting for proper hight to reach...");
}
break;
case 3:
printf("lever is activated\n");// activated the lever
printf("hydralic pump value is changed\n");// change the value
lan_f_state=4;
break;
case 4:
if (f_wheel==1)// check the wheel position
{
printf("wheel is properly get out\n");
printf("extended process is complete");
lan_f_state=5;
}
else// wait for wheel get in
{
printf("wait for wheel get out...");
}
break;
case 2:
printf("door open\n");// close the door
lan_f_state=3;
break;
}
}
void take__off()// function defination
{
switch (take_f_state)
{
case 0:
printf("retracted process start..,\n");// first state
take_f_state=1;
break;
case 1:
if(f_hight>200)// check the hight
{
printf("proper hight is reached \n");
take_f_state=2;
}
else// else wait for hight is reached
{
printf("waiting for proper hight to reach...");
}
break;
case 2:
printf("lever is activated\n");// activated the lever
printf("hydralic pump value is changed\n");// change the value
take_f_state=3;
break;
case 3:
if (f_wheel==1)// check the wheel position
{
printf("wheel is properly get in\n");
take_f_state=4;
}
else// wait for wheel get in
{
printf("wait for wheel get in...");
}
break;
case 4:
printf("door closed\n");// close the door
printf("retracted process is completed");// process is complete
take_f_state=5;
break;
}
}
Expected Outcomes:

