Challenge

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

Overview of the project:

1.Here, user given the First linked list quantity of data like 5.

2.Then user provide the sset of data of First list=[1,2,3,4,5].

3.They given the Second linked list quantity of data like 5.

4.Then user provide the sset of data of First list=[4,5,6,7,8].

5.After that we can apply the union and intersection of these data First list, Second list.

Goals:

1.Implementation of interface for mathematical set theory using c programming.

2.Giving two list of data as input to get the output as union & intersection for Given list of data.

3.Union and intersection do from the given two set of data.

Key highlights of the project:

  1. Creating two linked list of data using single linked list.
  1. Insertion is using for insert the data from one data to another data accordingly.
  1. Intersection is identify or taken the elements which are present same in both lists.
  1. All the elements that are in at least one of the two list.

Deliverable of the Project:

  1. Intersection is identify the same element of both First and Second list.
  1. Here, interestion is indenty the 4,5 data is common in both the list.
  1. Union it's help to arrange all the data from top to bottom order with help of two list. But it will not take 2 same data in both the list, it will take only data.
  1. Here, union is arrange the both list : 8,7,6,5,4,3,2,1.

Expected outcomes:

  1. Here using single linked list, it is the simplest form of a linked list.
  1. Linked list ia a linear data structure contain a collection of data elements called nodes.
  1. Intersection data, traverse through the first list, and look for every element in the second list. If the element is present in the second list, then add that element to the result list.
  1. Union data, traverse through the first list and add all of its elements to the result list. Now, traverse through the second list. If an element of the second list is already present in the result list.


project 2:

#include<stdio.h>

#include<stdlib.h>

#include<stdint.h>

#include<string.h>

void Initiate_State_Machine();

void Gear_down();

void Checking_Before_TakeOFF_delay_3s();

void Raising_Gear();

void Gear_up();

void Checking_before_landing();

void Lowering_gear();

typedef enum

{

GEAR_DOWN,

CHECKING_BEFORE_TAKEOFF_DELAY_3S,

RAISING_GEAR,

GEAR_UP,

CHECKING_BEFORE_LANDING,

LOWERING_GEAR

}State_Types;

typedef enum

{

open,// value 0

close // value 1

}Switch;

typedef enum

{

raising,//value 0

falling,//value 1

up,//value 2

down//value 3

}pilot_Lever;

typedef enum

{

Working,

Not_working

}Hydralic;

static volatile Switch limit_switch,squat_switch;

static volatile pilot_Lever pil;

static volatile Hydralic operation;

State_Types current_state;

typedef struct

{

char* currentstate;

char* lightvalue;

char* directionValve;

char* Hydraliccontrol;

}state;

static void(*state1[])(void)={Gear_down,Checking_Before_TakeOFF_delay_3s,Raising_Gear,Gear_up,Checking_before_landing,Lowering_gear};

state state_machine[6]={{"GearDown", "Green", "Down", "Enabled"},

{"Checkingbeforetakeoff", "Green","Down", "Enabled"},

{"Raising Gear", "Red", "Up", "Enabled"},

{"Gearup", "off", "Null", "Disabled"},

{"Checking before landing", "Red","Down", "Enabled"},

{"Loweringgear", "Green", "Down", "Enabled"}};

int main()

{

Initiate_State_Machine();

while(1)

{

state1[current_state]();

}

}

void Initiate_State_Machine()

{

current_state = GEAR_DOWN;

printf("The Finite State Machine is Initialized and current the program is in"

"GEARDOWN State & Light is: %s\n",state_machine[current_state].lightvalue);

}

void Gear_down()

{

current_state=GEAR_DOWN;

printf("Enter the values of pil and Squatswitch: ");

fflush(stdout);

scanf("%d %d",&pil,&squat_switch);

if(pil==raising && squat_switch==close)

{

current_state=CHECKING_BEFORE_TAKEOFF_DELAY_3S;

printf("\n status of currentstate is %s",state_machine[current_state].currentstate);

printf("\n status of lightvalue is %s",state_machine[current_state].lightvalue);

}

else

{

Gear_down();

}

}

void Checking_Before_TakeOFF_delay_3s()

{

current_state= CHECKING_BEFORE_TAKEOFF_DELAY_3S;

printf("\nEnter the values of pil and Squatswitch and operation");

fflush(stdout);

scanf("%d %d %d",&pil,&squat_switch,&operation);

if(pil==falling && squat_switch==close)

{

current_state=GEAR_DOWN;

printf("\n status of currentstate is %s",state_machine[current_state].currentstate);

printf("\n status of lightvalue is %s",state_machine[current_state].lightvalue);

printf("\n status of directionValve is %s",state_machine[current_state].directionValve);

printf("\n status of Hydraliccontrol is %s",state_machine[current_state].Hydraliccontrol);

}

if(pil==raising && operation==Working)

{

current_state=RAISING_GEAR;

printf("\n status of currentstate is %s",state_machine[current_state].currentstate);

printf("\n status of lightvalue is %s",state_machine[current_state].lightvalue);

printf("\n status of directionValve is %s",state_machine[current_state].directionValve);

printf("\n status of Hydraliccontrol is %s",state_machine[current_state].Hydraliccontrol);

}

else

{

Checking_Before_TakeOFF_delay_3s();

}

}

void Raising_Gear()

{

current_state=RAISING_GEAR;

printf("\nEnter the values of pil and limit_switch");

fflush(stdout);

scanf("%d %d",&pil,&limit_switch);

if(pil==falling && limit_switch == open)

{

current_state=CHECKING_BEFORE_LANDING;

printf("\n status of currentstate is %s",state_machine[current_state].currentstate);

printf("\n status of lightvalue is %s",state_machine[current_state].lightvalue);

printf("\n status of directionValve is %s",state_machine[current_state].directionValve);

printf("\n status of Hydraliccontrol is %s",state_machine[current_state].Hydraliccontrol);

}

if(pil==up &&limit_switch==close)

{

current_state=GEAR_UP;

printf("\n status of currentstate is %s",state_machine[current_state].currentstate);

printf("\n status of lightvalue is %s",state_machine[current_state].lightvalue);

printf("\n status of Hydraliccontrol is %s",state_machine[current_state].Hydraliccontrol);

}

else

{

Raising_Gear();

}

}

void Gear_up()

{

current_state=GEAR_UP;

printf("\nEnter the values of pil ");

fflush(stdout);

scanf("%d",&pil);

if(pil==falling)

{

current_state=CHECKING_BEFORE_LANDING;

printf("\n status of currentstate is %s",state_machine[current_state].currentstate);

printf("\n status of lightvalue is %s",state_machine[current_state].lightvalue);

printf("\n status of Hydraliccontrol is %s",state_machine[current_state].Hydraliccontrol);

}

else

{

Gear_up();

}

}

void Checking_before_landing()

{

current_state=CHECKING_BEFORE_LANDING;

printf("\nEnter the values of pil and operation");

fflush(stdout);

scanf("%d %d",&pil,&operation);

if(pil==falling || operation==Not_working)

{

current_state=LOWERING_GEAR;

printf("\n status of currentstate is %s",state_machine[current_state].currentstate);

printf("\n status of lightvalue is %s",state_machine[current_state].lightvalue);

printf("\n status of directionValve is %s",state_machine[current_state].directionValve);

printf("\n status of Hydraliccontrol is %s",state_machine[current_state].Hydraliccontrol);

}

else

{

Checking_before_landing();

}

}

void Lowering_gear()

{

current_state=LOWERING_GEAR;

printf("\nEnter the values of pil and limit_switch");

fflush(stdout);

scanf("%d %d",&pil,&limit_switch);

if(pil == down && limit_switch==open)

{

current_state=GEAR_DOWN;

printf("\n status of currentstate is %s",state_machine[current_state].currentstate);

printf("\n status of lightvalue is %s",state_machine[current_state].lightvalue);

printf("\n status of Hydraliccontrol is %s",state_machine[current_state].Hydraliccontrol);

}

if(pil==raising && limit_switch == close)

{

current_state=CHECKING_BEFORE_TAKEOFF_DELAY_3S;

printf("\n status of currentstate is %s",state_machine[current_state].currentstate);

printf("\n status of lightvalue is %s",state_machine[current_state].lightvalue);

printf("\n status of Hydraliccontrol is %s",state_machine[current_state].Hydraliccontrol);

}

else

{

Lowering_gear();

}

}

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.