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
How do you compute the integral of a function using midpoint rule in C programming? What is the longetiviity of asphalt shingles? How do you write a java program that display the non-zero denominations only Display singular words for single units like 1 dollar and 1 penny and display plural words for more than one unit 2 dols? What is the typical life of a Semiconductor IC? What is the advantage of using a bar graft? What carpet glue or adhesive to use to install a stairway carpet with urethane laminated underlay? What are signals composed of pulses of precise positive voltages and zero voltages? Can you help with arrays in DrJava I have to edit the code for my class at UofP Getting... Error No 'fillArray' method in 'Five' with arguments? Will three quarter inch waterline carry as much water as 2 half inch waterlines? What is m3a64a steel? Co2 oxygen both use same time in mig welding? Write a program in c plus plus to accept the string and then take the starting and ending point from the user and display the sub string through function? What Is The Dependence Of Device Capacitance (C) On Applied Reverse Bias (V) For An Abrupt Junction Varactor Diode? Where did Charles Macintosh raincoat inventor go to school? What would most likely lead to a successful IPO? Why does it matter how a writer organizes a technical document? What are unsustainable materials? What font is THX? How do cut an elbow at any degree in a pipe? What three factors determine the strength of a truss bridge?