c - The Output screen freezes after taking the first input and the graphics VDU is not displayed -
my code compiles without warnings , errors when run it, output screen freezes after accepting first input , stops responding abruptly after can't apparently spot bug(s) in code.
//conway's game of life #include<stdio.h> #include<stdlib.h> #include<graphics.h> #include<conio.h> void setup() { int x,y,gd=detect,gm,i=0,j,n,a[181][181]; unsigned long turns; printf("enter number of pixels = "); scanf("%d",&n); printf("enter number of turns = "); scanf("%lu",&turns); srand(time(0)); initgraph(&gd,&gm,"c://turboc3//bgi"); setbkcolor(11); for(i=0;i<181;i++) { for(j=0;j<181;j++) a[i][j]=0; } for(i=1;i<=n;i++) { x=rand()%181; y=rand()%181; a[y][x]=1; putpixel(x,y,4); } } void main() { clrscr(); setup(); getch(); closegraph(); }
Comments
Post a Comment