answersLogoWhite

0

Its quite easy to code an simulation program in c. An Sample Simulation program in c for Traffic Signal

#include<graphics.h> #include<conio.h> #include<dos.h> #include<stdlib.h> main() { int gd = DETECT, gm, midx, midy; initgraph(&gd, &gm, "C:\\TC\\BGI"); midx = getmaxx()/2; midy = getmaxy()/2; setcolor(RED); settextstyle(SCRIPT_FONT, HORIZ_DIR, 3); settextjustify(CENTER_TEXT, CENTER_TEXT); outtextxy(midx, midy-10, "Traffic Light Simulation"); outtextxy(midx, midy+10, "Press any key to start"); getch(); cleardevice(); setcolor(WHITE); settextstyle(DEFAULT_FONT, HORIZ_DIR, 1); rectangle(midx-30,midy-80,midx+30,midy+80); circle(midx, midy-50, 22); setfillstyle(SOLID_FILL,RED); floodfill(midx, midy-50,WHITE); setcolor(BLUE); outtextxy(midx,midy-50,"STOP"); delay(2000); graphdefaults(); cleardevice(); setcolor(WHITE); rectangle(midx-30,midy-80,midx+30,midy+80); circle(midx, midy, 20); setfillstyle(SOLID_FILL,YELLOW); floodfill(midx, midy,WHITE); setcolor(BLUE); outtextxy(midx-18,midy-3,"READY"); delay(2000); cleardevice(); setcolor(WHITE); rectangle(midx-30,midy-80,midx+30,midy+80); circle(midx, midy+50, 22); setfillstyle(SOLID_FILL,GREEN); floodfill(midx, midy+50,WHITE); setcolor(BLUE); outtextxy(midx-7,midy+48,"GO"); setcolor(RED); settextstyle(SCRIPT_FONT, HORIZ_DIR, 4); outtextxy(midx-150, midy+100, "Press any key to exit..."); getch(); closegraph(); return 0; }

User Avatar

Wiki User

12y ago

What else can I help you with?

Trending Questions
Quality and reliability are related concepts but are fundamentally different in a number of ways Discuss them? Can use stone dust as a filler material for bituminous concrete? How do you calculate how to split a 7.5Kw load over 3 phases? Why do people need to develop alternative sources of renewable energy and become less dependent on fossil fuels? What is the organizational structure of management in a power plant? How is a Residual Current Device or RCD different to a Ground Fault Circuit Interrupter or GFCI? What is the minimum value of power factor of a circuit can have under what circumstances can this occur? How data is represented in dbms? Why converting a base class pointer to a derived class pointer is consider dangerous by the compiler? What is the minimum value of Ir test in 11kv cables? If you are considering Ch 7 but do not want to include a newly purchased vehicle are you able to still file? In which layer will liquid petroleum be found in the oil trap shown in figure 4-1? What is better civil or electronics for engineering? What are the codes called that surround the HTML text? Accidentally drop cardboard down the toilet how do you get it out? Purpose of minimum flow line for centrifugal pump? How is hooke's law releted to torque wrench action? What are the procedure of construction of a well foundation? Is there a way to calculate the physical length of the groove on a compact disc based on the time length of the track? Which error is the violation of grammar rules of a programming language?