Convenit way of printing string Get link Facebook X Pinterest Email Other Apps - August 20, 2020 #include<stdio.h>int main(){ // int a = 4; // printf("%d", a); // char *ptr = "sunil bhai"; char ptr[] = "sunilkumar"; printf("%s", ptr); return 0;} Get link Facebook X Pinterest Email Other Apps Comments
Snake game.c - August 14, 2020 #include<STDLIB.H> #include<stdio.h> #include<conio.h> #include<time.h> int height =23 ,width =78,x,y,fruitx,fruity,score,gameend,flag; int tailx[100],taily[100]; int piece=0; //x = height and y= width void makelogic(){ int i ; int prevx,prevy,prev2x,prev2y; prevx=tailx[0]; prevy=taily[0]; tailx[0]=x; taily[0]=y; for(i =1;i <=piece;i++){ prev2x=tailx[i]; prev2y=taily[i]; tailx[i]=prevx; taily[i]=prevy; prevx=prev2x; prevy=prev2y; } switch(flag){ case 1: x--; break; case 2: x++; break; case 3: y--; break; case 4: y++; break; } if(x==0||y==0||x==height||y==width){ gameend = 1; } if(x==fruitx && y == fruity){ label3: fruitx = rand ()%23 ; if (fruitx==0){ goto label3; } label4: fruity = rand ()%78 ; if (fruity==0) goto label4; score++; piece++; } } void input(){ ... Read more
Rainbow - August 26, 2020 #include<stdlib.h> #include<graphics.h> #include<conio.h> #include<dos.h> int main(){ int gd = DETECT,gm,i,x,y; initgraph(&gd,&gm,"c:\\tc\\bgi"); for (i = 30;i<=200;i++){ delay(100); setcolor(i/10); arc(getmaxx()/2,getmaxy()/2,0,180,i); } getch(); closegraph(); } Read more
bird game - August 23, 2020 #include<stdio.h> #include<conio.h> #include<dos.h> #include<time.h> int x=5,y=2,gameend =0,w1,e,upl=2,upb=50,ch = 0 ,upl2 = 2; int upb2 = 70,downl1 = 9,downb1 = 60,downb2 = 77,downl2 = 9; int upl3= 2,upb3 =35 ,downl3 =9 ,downb3 = 50,score = 0; void draw(); void move(); int main(){ while(gameend != 1) { clrscr(); draw(); move(); score++; delay(300); } clrscr(); printf("score = %d",score); getch(); return 0; } void draw() { int l,b; for (l=0;l<10;l++) { for(b=0;b<78;b++){ if (l==0||l==9||b==0){ printf("-"); } else if ( ch == 15){ ch =0; } else if(l==x&&b==y){ printf("0"); } else if(upb-1 == b&&upl-1 == l){ printf("|"); upb--; } else if(upb == b&&upl == l){ printf("|"); } else if(upb2-1 == b&&upl2-1 == l){ printf("|"); upb2--; } else if(upb2 == b&&upl2 == l){ printf("|... Read more
Comments
Post a Comment