Challenge

Project 2 - Implement the Code for controlling the retraction and extension of Airplane’s landing gear

CODE FOR CONTOLLING THE RETRACTION AND EXTENSION OF AIRPLANE LANDING GEAR

#include<stdio.h>

#include<string.h>

//variables

int take_f_state=0;

int lan_f_state=0;

int f_height=250;

int f_wheel=1;

char name_1[]="takeoff";

char name_2[]="landing";

//function

void takeoff();

void landing();

int main()

{

//local variable

char pro[10];

printf("enter the process :");

//get input from user

scanf("%s",pro);

//check the condition

if((strcmp(pro,name_1))==0)

{

while(1)//run until the process is end

{

takeoff();

if(take_f_state==5)//check the condition

{

take_f_state=0;

break;

}}}

if((strcmp(pro,name_2))==0)//check the condition

{

while(1)//run until the process is end

{

landing();

if(lan_f_state==5)//check the conditions

{

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_height>200)//check the height

{

printf("proper height is reached\n");

lan_f_state=2;

}

else//else wait for height is reached

{

printf("waiting for proper height to reach...");

}

break;

case 3:

printf("level is activated\n");//activate the lever

printf("hydralic pump valve");//change valve

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

{

printf("wait for wheel get out...");

}

break;

case2:

printf("door open\n");

lan_f_state=3;

break;}}

void takeoff()

{

switch(take_f_state){

case 0:

printf("retracted process start..,\n");

take_f_state=1;

break;

case 1:

if(f_height>200)//check the height

{

printf("proper height is reached\n");

take_f_state=2;

}

else//else wait for height is reached

{

printf("waiting for proper height to reach..");

}

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 completed

take_f_state=5;

break;

}}

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.