Challenge

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

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

-->

#include<stdio.h>
#include<string.h>
char Lights[10];
char Lever[10];

void Set_Light_Red()
{
	strcpy(Lights, "Red");
}/*function to set light RED*/

void Set_Light_Green()
{
	strcpy(Lights, "Green");
}/*function to set light Green*/

void Set_Light_OFF()
{
	strcpy(Lights, "OFF");
}/*function to set light OFF*/

char * Get_light()
{
	return Lights;
}/*function to Get light Status*/

void Set_lever_up()
{
	strcpy(Lever, "Up");
}/*function to set lever up*/

void Set_lever_down()
{
	strcpy(Lever, "Down");
}/*function to set lever Down*/

char * Get_lever()
{
	return Lever;
}/*function to get lever Status*/

void Take_Off()
{
	int i = strcmp(Get_light(),"Red");
	if(i>0)
		printf("\nCan not takeoff, light are not Red\n");
	else
	{
		Set_lever_up();
		Set_Light_OFF();
		printf("\nTakeoff Success\n");
	}
}/*Function to take off*/

void Landing()
{
	int i = strcmp(Get_light(),"Green");
	if(i>0)
		printf("\nCan not Land, lights are not Green\n");
	else
	{
		Set_lever_down();
		printf("\nLanding Success\n");
	}
}/*Function to landing*/
int main()
{
	Set_Light_Red();
	Take_Off();
	Set_Light_Green();
	Landing();

	return 0;
}/*main function to operate*/

Output:

Takeoff Success

Landing Success

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.

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.