Challenge

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

#include
#include

char lights[10], lever[10];

void setLightsRed(){
strcpy(lights, "Red");
}

void setLightsGreen(){
strcpy(lights, "Green");
}

void setLightsOff(){
strcpy(lights, "Off");
}

char* getLights(){
return lights;
}

void setLeverUp(){
strcpy(lever, "Up");
}

void setLeverDown(){
strcpy(lever, "Down");
}

char* getLever(){
return lever;
}

char* takeOff(){
if(strcmp(getLights(), "Red") != 0){
return "Can't take off because lights are not red\n";
}
setLeverUp();
setLightsOff();
return "Take Off Success\n";
}

char* landing(){
if(strcmp(getLights(), "Green") != 0){
return "Can't land because lights are not Green\n";
}
setLeverDown();
return "Landing Success\n";
}

int main(){
setLightsRed();
printf("%s", takeOff());
setLightsGreen();
printf("%s", landing());
return 0;
}

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.