answersLogoWhite

0


Best Answer

/*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
This answer is:
User Avatar

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
Continue Learning about Engineering

Write Client and server program in C language using UDP?

Write and run a client and a server program in C-language using UDP


Can you write program by c language in dos?

Yes.


Connect c language to internet database?

Yes, you can write a program in C language which connects to a database.


How can program for c language?

first think of the logic and then write the statements


How do you Write A program in c language for checking a diagonal matrix?

Write a program in c++ that take input in a integer matrix of size 4*4 and find out if the entered matrix is diagonal or not.

Related questions

Write Client and server program in C language using UDP?

Write and run a client and a server program in C-language using UDP


Can you write program by c language in dos?

Yes.


How do you write an Algorithm for a C plus plus Program?

You don't write an algorithm for a C++ program, unless you are documenting the C++ program after-the-fact. The normal procedure is to write the algorithm first, in a language independent fashion, and then translate that stated algorithm into C++ code, or into whatever language you wish.


Connect c language to internet database?

Yes, you can write a program in C language which connects to a database.


Write an assembly language program to print a to z on screen?

write a program to print A to Z on screen in c?


Write down a program for hotel management in c language?

ponka


How can program for c language?

first think of the logic and then write the statements


Write a program of binary heap in c or c language?

to implement operations on binary heap in c


How to write a Program in C language to draw a house?

here you go nah...


How do you write palindrome program in c language?

int pallindrom(int p){ /*write all logic*/ }


Write a program in FORTRAN C language to compute control ratios used in budgeting with reference to any organization?

if u give control ratios used in budgeting i can write program in C/C++


How do you Write A program in c language for checking a diagonal matrix?

Write a program in c++ that take input in a integer matrix of size 4*4 and find out if the entered matrix is diagonal or not.