Area of square Get link Facebook X Pinterest Email Other Apps - August 20, 2020 #include<stdio.h>#include<math.h>int main(){ int side; printf("Enter the value of side\n"); scanf("%d", &side); printf("The value of area is %f", pow(side,2)); 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
Rocket game - August 24, 2020 #include<stdio.h> #include<conio.h> #include<graphics.h> #include<time.h> int l = 10,b = 60,x=4,y=4,gameend = 0; int ex = 50,ey= 8,r1,ex2 = 59,ey2= 5,r2; int ex3 = 40,ey3 = 2,r3,score = 0; void home(); void control(); void draw(); int main(){ home(); while(gameend != 1){ clrscr(); draw(); control(); delay(200); } clrscr(); printf("score = %d ",score); getch(); return 0; } void draw(){ int i,k; for(i=0;i<l;i++){ for(k=0;k<b;k++){ if(i==0||k==0||i==9||i==6||i==3){ printf("*"); } else if(i==y&&k==x||i==y+1&&k==x){ printf(")"); } else if(i==y&&k==x+1||i==y+1&&k==x+1){ printf("0"); } else if(i ==y&&k==x+2){ printf("0"); } else if(i ==y+1&&k==x+2){ printf("0"); } else if(i ==y&&k==x+3){ printf("0"); } else if(i ==y+1&&k==x+3){ printf("0"); } else if(i == ey&&k==ex){ printf(... Read more
Tic tac tic game - August 21, 2020 #include<stdio.h> #include<conio.h> int gameover=1; char a[9] = {'1','2','3','4','5','6','7','8','9'}; char p1name[20],p2name[20]; char symbol1='x',symbol2 = '0'; int player1,player2,ch = 0; void input(); void show(); void win(); int main(){ clrscr(); printf("enter player 1 name : "); scanf("%s",p1name); printf("enter player 2 name : "); scanf("%s",p2name); while(gameover!= 0){ clrscr(); show(); input(); win(); } clrscr(); show(); win(); getch(); return 0; } void show(){ printf("\t\t\t\t TIC TAC TIC\n"); printf("\n\n"); printf("\t\t\t--|--|--\n"); printf("\t\t\t%c |%c |%c \n",a[0],a[1],a[2]); printf("\t\t\t--|--|--\n"); printf("\t\t\t%c |%c |%c \n",a[3],a[4],a[5]); printf("\t\t\t--|--|--\n"); printf("\t\t\t%c |%c |%c \n",a[6],a[7],a[8]); print... Read more
Comments
Post a Comment