Challenge

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

//RAJU MANGALWEDE SIR

//ANSWER :

#include<stdio.h>

void switchisdown();

void switchisup();

static void (*statetable[])(void)={switchisup,switchisdown};

typedef enum state

{

off_zero,

on_one

}state_type;

typedef enum sw1

{

off,

on

}sw1_status;

static volatile sw1_status squat_switch;

state_type currentstate;

typedef struct

{

char *switchdescription;

char *light;

}State_table;

static State_table State_machine[2]={{"switch is on","lights are green"},{"switchisoff"," lights are Red"}};

int main()

{

// printf("Current state value: %d", currentstate);

statetable[currentstate]();

// printf("\nCurrent state value: %d", currentstate);

statetable[currentstate]();

}

void switchisup()

{

printf("\n switch getting activated");

currentstate=off_zero;

printf("\n %s",State_machine[currentstate].switchdescription);

printf("\n %s",State_machine[currentstate].light);

currentstate=on_one;

}

void switchisdown()

{

printf("\n switch getting deactivated");

printf("\n %s",State_machine[currentstate].switchdescription);

printf("\n %s",State_machine[currentstate].light);

}

//NB: Header files is missing while uploading the program,please note and do the needful

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.