answersLogoWhite

0

/*This is a simple Program*/

#include <stdio.h>

#include <stdlib.h>

#include <windows.h>

#include <conio.h>

int main()

{

int curfl = 0, destfl, floor;

float high, speed;

float time1;

high = 3.0; // Height of the floor

speed = 5.0; // Speed of the elevator per second

while(1)

{

printf("Currently the elevator is at floor number = %d\n", curfl);

printf("Enter the floor number between 0-25 : ");

// printf("%d %d", &curfl, &time1);

scanf("%d", &destfl);

if(destfl > curfl)

{

floor = destfl - curfl;

time1 = (floor * (high / speed));

printf("Elevator will take %.2f second to reach %d (st, nd, rd) floor \n", time1, destfl);

while(curfl != destfl)

{

Sleep((1000 * 3) / 5);

curfl++;

printf("You are at floor number %d \n", curfl);

}

printf("Door opening \n");

Sleep(10000);

printf("Door Closed\n \n");

}

else if(destfl < curfl)

{

floor = curfl - destfl;

time1 = (floor * (high / speed));

printf("Elevator will take %.2f second to reach %d (st, nd, rd) floor \n", time1, destfl);

while(curfl != destfl)

{

Sleep((1000 * 3) / 5);

curfl--;

printf("You are at floor number %d \n", curfl);

}

printf("Door opening \n");

Sleep(10000);

printf("Door Closed\n \n");

}

else{

printf("You are the same floor. Please getout from the elevator \n");

}

}

// printf("Hello world!\n");

return 0;

}

User Avatar

Wiki User

12y ago

Still curious? Ask our experts.

Chat with our AI personalities

LaoLao
The path is yours to walk; I am only here to hold up a mirror.
Chat with Lao
BlakeBlake
As your older brother, I've been where you are—maybe not exactly, but close enough.
Chat with Blake
MaxineMaxine
I respect you enough to keep it real.
Chat with Maxine

Add your answer:

Earn +20 pts
Q: How do you write elevator program in c language?
Write your answer...
Submit
Still have questions?
magnify glass
imp