answersLogoWhite

0


Best Answer

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

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

#include <stdio.h>

int main (void) { puts ("Here is my homework"); return 0; }

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write a simulation program in C?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a c program for creating a virus?

a c program for creat a virus


Where do we write main function in a c program?

Into the source program.


Write a c program to find Volume and surface area of cube?

Write a c program to compute the surface area and volume of a cube


How do you write a c program to analysis a circuit?

There is no need to write a C program for circuit analysis; there are lots of packages out there that already do that (for example, Spice).


What does simulation mean in ICT?

simulation is a bad word write


How do you write a C program to check whether the number is odd or even Ps-using DEV complier?

To write a C program to determine if something is odd or even you need to be a programmer. To write a program in C is complicate and only done by programmers.


What has the author C H Orr written?

C. H. Orr has written: 'A user manual for graphical interactive pump analysis and simulation program(GIPAS)' 'Optimized pumping in water supply systems' 'Computer-aided pump analysis, design and simulation, using the program GIPADS' 'User manual for GINAS input data file preparation program(GIDAT)'


How do you write socket program in c?

For first find an example program.


How do you write a program in embedded c?

Use a text-editor program.


What is the program to write route cipher?

c#


Write a program in c for checksum?

yes


Write a program to illustrate the usage of pointers with arrarys and functions?

* * * * * * * * * * write the c++ program and show me brifily?