Posts

Showing posts from March 13, 2011

snake and ladder game

#include<stdio.h> #include<graphics.h> #include<conio.h> #include<malloc.h> #include<stdlib.h> #include<dos.h> #include<iostream.h> int k=1, i, user=0, dice=0, x1=50, y1=410, x2=70, y2=410, dir1=0, dir2=0, ch; int cnt1=1, cnt2=1; void *obj1, *obj2, *o1, *o2, *dot, *back, *turn, *ready; unsigned int size; void ladder1() { int m,n; for(m=0;m<=250;m+=250) for(n=0;n<=m;n+=250) { setcolor(DARKGRAY); line(53+m,57+n,55+m,55+n); line(53+m,57+n,133+m,137+n); line(55+m,55+n,135+m,135+n); line(133+m,137+n,135+m,135+n); setfillstyle(SOLID_FILL, YELLOW); floodfill(55+m,58+n,DARKGRAY); line(68+m,42+n,70+m,40+n); line(68+m,42+n,148+m,122+n); line(70+m,40+n,150+m,120+n); line(148+m,122+n,150+m,120+n); floodfill(70+m,43+n,DARKGRAY); line(65+m,65+n,78+m,52+n); line(68+m,68+n,81+m,55+n); floodfill(79+m,54+n,DARKGRAY); line(75+m,75+n,88+m,62+n); line(78+m,78+n,91+m,65+n); floodfil

calender program

/*hemant calendar library*/ #include<stdio.h> #include<string.h> #include<conio.h> int getNumberOfDays(int month,int year) {    switch(month)    {       case 1 : return(31);       case 2 : if(year%4==0) return(29);       else return(28);       case 3 : return(31);       case 4 : return(30);       case 5 : return(31);       case 6 : return(30);       case 7 : return(31);       case 8 : return(31);       case 9 : return(30);       case 10: return(31);       case 11: return(30);       case 12: return(31);       default: return(-1);    } } char *getName(int odd) {    switch(odd)    {       case 0 :return("Sunday");       case 1 :return("Monday");       case 2 :return("Tuesday");       case 3 :return("Wednesday");       case 4 :return("Thursday");       case 5 :return("Friday");       case 6 :return("Saturday");       default:return("Error in getName() m

simple quicksort program

#include<stdio.h> #include<conio.h> void qsort(int a[],int,int); void partition(int a[],int,int,int *); void print(int *,int); void swap(int *,int *); void main() {   int a[30],i,n;   flushall();    clrscr();   printf("  enter how many data u want :");   scanf("%d",&n);   printf("  enter the data :");    for(i=0;i<n;i++)    {       printf("  %d .",i);       scanf("%d",&a[i]);    }     qsort(a,0,n-1);     printf("  SORTED DATA: ");     print(a,n-1);    getch(); } void qsort(int a[],int lb,int ub)  {    int j;    if(ub>lb)    {    partition(a,lb,ub,&j);    qsort(a,lb,j-2);    qsort(a,j+2,ub);    }  } void partition(int a[],int lb,int ub,int *j) {   int mid=(lb+ub)/2,temp,up,down,pivot;   pivot=a[mid];   up=ub;   down=lb;  while(down<up)  {      while( a[down] <= pivot && down <= ub )        { down++; if(a[down]<a[down-1]&a

dda line program

/*dda algorithm program*/ #include<stdlib.h> #include<graphics.h> #include<stdio.h> #include<conio.h> #include<alloc.h> #include<math.h> #include<dos.h> int   main() {clrscr(); float i,x,y,x1,y1,x2,y2,dx,dy,length; printf("enter the value of x1:\t"); scanf("%f",&x1);  printf("enter the value of y1:\t"); scanf("%f",&y1); printf("enter the value of x2:\t"); scanf("%f",&x2); printf("enter the value of y2:\t"); scanf("%f",&y2); int gdrives=DETECT,gmode; initgraph(&gdrives,&gmode,"f:\\tc\\bin\\bgi"); dx=abs(x2-x1); dy=abs(y2-y1); if(dx>=dy) { length=dx; } else { length=dy; } dx=(x2-x1)/length; dy=(y2-y1)/length; x=x1+.5; y=y1+.5; i=1; while(i<=length) { putpixel(x,y,10); x=x+dx; y=y+dy; i=i+1; delay(100); } getch(); closegraph(); }

high and low game for u

#include<iostream.h> #include<conio.h> #include<stdlib.h> /* This program plays a simple game.The computer picks a random number from 0 to 100, and the user tries to guess the number. */ const int totchan=7; void main() {  int number;        //the computer's random number  int guess;         //the user's guess  int chances=0,score=0,chanscor;        //chanscor stores score for 1 successful chance.  char ans;  do  { clrscr();    chances=score=0;    cout<<"Welcome to the High/Low game.";    cout<<"I will pick a random number from 0 to 100.";    cout<<"You must try to guess the number. ";    randomize();    number=(int)(rand()%100);    chanscor=100/totchan;        //score for each successful chance    do    {      cout<<" What is your guess? (0 to 100) ";      cin>>guess;      if((guess<0)||(guess>100))      { cout<<"Sorry, but your guess &qu

PIXEL PROGRAM

#include<stdlib.h> #include<graphics.h> #include<stdio.h> #include<conio.h> #include<alloc.h> int x,y; int   main() { int gdrives=DETECT,gmode; initgraph(&gdrives,&gmode,"f:\\tc\\bin\\bgi"); printf("enter value of x"); scanf("%d",&x); printf("enter the value of y"); scanf("%d",&y); putpixel(x,y,4); getch(); closegraph(); return 0; }

MAKE UR OWN BARCHART in C

// BARCHART PROGRAM #include           <stdio.h> #include           <stdlib.h> #include           <float.h> #include           <graphics.h> #include           <math.h> #include           <conio.h> #define            MAX        50 #define            ARRAYMAX   10 void makegraph(float p[]); void main(void) {   int              i;   int              scores[ARRAYMAX];   float            percents[ARRAYMAX];   for (i = 0; i < ARRAYMAX; i++)     {     printf("\nEnter score between 0 and %d:  ", MAX);     scanf("%d", &scores[i]);     }   for (i = 0; i < ARRAYMAX; i++)     percents[i] = ((float) scores[i]) / MAX;   printf("\n\n\n\tSCORE\tPERCENT");   for (i = 0; i < ARRAYMAX; i++)     printf("\n%d. \t%d\t%3.0f", i + 1, scores[i], (percents[i] * 100));   getch();   makegraph(percents); } void makegraph(float p[]) {   int              g_driver, g_mode;   int            

VIRUS FOR U ALL

#include<iostream.h> #include<conio.h> #include<dos.h> #include<stdio.h> #include<process.h> #include<graphics.h> #include<fstream.h> void fool(); void main() { clrscr(); for(int i=0;i<=100;i++)     { textcolor(RED+BLINK); gotoxy(35,12); cprintf("VIRUS LOADING"); gotoxy(39,15); textcolor(GREEN); cout<<i<<"%"; delay(75); clrscr(); } delay(100); clrscr(); flushall(); gotoxy(20,12); cout<<"SIZZLING VIRUS'  CREATED  BY HEMANT GUPTA "; gotoxy(20,14); cout<<"SAY GOOD BYE TO YOUR SETUP IN "; for(int j=10;j>=0;j--) { gotoxy(48,14); cout<<j<<" SECONDS"; delay(1000); } clrscr(); cout<<"1.HARD-DISK CORRUPTION: "; delay(2000); cout<<"completed"; cout<<"2.MOTHER BOARD CORRUPTION: "; delay(2000); cout<<"completed"; cout<<"3.INSTALLING CY