i will provde u a basic C language program which will give o/p as a bomb
#include
#include
#include
void main()
{
int i, j, r, c, s, main;
char ans, opt;
menu:textbackground(BLUE);
textcolor(YELLOW + BLINK);
clrscr();textbackground(BLUE);
textcolor(YELLOW + BLINK);
do{gotoxy(24, 6);
printf("%c", 15);
gotoxy(33, 4);
printf("%c", 15);
gotoxy(40, 6);
printf("%c", 15);
gotoxy(50, 5);
printf("%c", 15);
gotoxy(60, 7);
printf("%c", 15);
gotoxy(70, 3);
printf("%c", 15);
gotoxy(18, 2);
printf("%c", 15);
gotoxy(7, 6);
printf("%c", 15);
gotoxy(18, 9);
printf("%c", 15);
gotoxy(63, 11);
printf("%c", 15);
gotoxy(20, 14);
printf("%c", 15);
gotoxy(57, 14);
printf("%c", 15);//Bfor(i = 8; i <= 12; i++){gotoxy(26, i);
printf("%c", 173);
gotoxy(30, i);
printf("%c", 173);
}
for(i = 8; i <= 12; i = i + 2)
{
gotoxy(27, i);
printf("%c%c%c", 173, 173, 173);
}//O
for(i = 8; i <= 12; i++)
{gotoxy(33, i);
printf("%c", 173);
gotoxy(37, i);
printf("%c", 173);
}
for(i = 8; i <= 12; i = i + 4)
{
gotoxy(34, i);
printf("%c%c%c", 173, 173, 173);
}//M
for(i = 8; i <= 12; i++)
{
gotoxy(40, i);
printf("%c", 173);
gotoxy(42, i);
printf("%c", 173);
gotoxy(44, i);
printf("%c", 173);
}
gotoxy(41, 8);
printf("%c", 173);gotoxy(43, 8);
printf("%c", 173);//Bf
or(i = 8; i <= 12; i++)
{
gotoxy(47, i);
printf("%c", 173);
gotoxy(51, i);
printf("%c", 173);
}
for(i = 8; i <= 12; i = i + 2)
{
gotoxy(48, i);
printf("%c%c%c", 173, 173, 173);
}
gotoxy(28, 15);
printf("T H E G A M E");
gotoxy(28, 19);
printf("1. New Game");
gotoxy(28, 20);
printf("2. Instructions.");
gotoxy(28, 21);
printf("3. Exit");
opt = getche();
if(opt == '1')
{
clrscr();
textbackground(BLUE);
textcolor(YELLOW + BLINK);
printf("ENTER THE SPEED WITH WHICH YOU WANT YOUR AEROPLANE TO MOVE ( > than 0 and < than 100): ");
scanf("%d", &s);
for(main = 1; main <= 3; main++)
{
clrscr();
textbackground(BLUE);
textcolor(YELLOW + BLINK);
gotoxy(37, 20);
printf("%c", 219);
gotoxy(1, 2);
printf(">%c--->", 173);
getch();
while(!kbhit())
{
for(i = 1; i < 75; i++)
{
if(kbhit())
{
getch();
nosound();
goto drop;
}
else{
gotoxy(i, 2);
printf(">%c--->", 173);
r = 2;
c = i;
gotoxy(37, 20);
printf("%c", 219);
sound(100);
delay(100 - s);
if(i != 36 && !kbhit())
{
clrscr();
textbackground(BLUE);
textcolor(YELLOW + BLINK);
}
}
}
}
drop:
for(j = 3; j <= 20; j++)
{
gotoxy(c, r);
printf(">---->");
gotoxy(37, 20);
printf("%c", 219);
gotoxy(i, j);
printf("%c", 173);
delay(50);
sound(3000);
if(j != 15)
{
clrscr();
textbackground(BLUE);
textcolor(YELLOW + BLINK);
}
}
nosound();
if(i == 37)
{gotoxy(34, 20);
printf("%cBOOM!!!%c", 15, 15);
gotoxy(29, 21);
//delay(100);
printf("%c %c %c", 15, 15, 15);
gotoxy(33, 19);//delay(100);
printf("%c %c", 15, 15);
for(i = 0; i < 10; i++)
{delay(30);
sound((i * 100) + 50);
delay(30);
nosound();
}
getch();
clrscr();textbackground(BLUE)
;textcolor(YELLOW + BLINK);
break;
}
else
{
gotoxy(i, 20);
clreol();
gotoxy(30, 15);
printf("SORRY, YOU MISSED THE TARGET");
sound(2000);
delay(100);
nosound();
}
getch();
}
}
}
while(opt == '1');
if(opt == '2')
{
clrscr();
textbackground(BLUE);
textcolor(YELLOW + BLINK);
printf("INSTRUCTIONS :-");
printf("\n\n\n");
printf("1. The objective of this game is to destroy the target by dropping a bomb on it.\n2. The player needs to drop the bomb from an aeroplane.\n\n3. Press any key to start flying the aeroplane.\n\n4. Then again press any key to drop the bomb when you are above the target.\n\n5. The target will look like this %c.", 219);
getch();
goto menu;
}
if(opt == '3')
{
}
else
{
goto menu;
}
}
if u got some error then solve it,i know u r genious one...... 6/25/08 by GeNiUs HaCkEr Delete
1 – 1 of 1
my program collection
all students informed that they r provided all program`s of all subject`s in engg.
Thursday, August 7, 2008
Wednesday, June 25, 2008
program based on matrix movie
CODE:
#include
#include
#include
#include
void main()
{
char c,d;
int i,j;
char a[15]={' ','A','D',' ','I','T','Y',' ','A',' ','A','D',' ','I','
'};//here characters are taken as my name
//u can change it to any other characters as yr own name
char far* p;
p=(char far*)0xb0008000;// vga memory address
clrscr();
randomize();
while(!kbhit())
{
delay(0);
for(i=0;i<160;i=i+6)
{
for(int j=0;j<50;j++)
{ *(p+160*j+i+1)=2;
*(p+160*j+i)=a[random(15)];
delay(0);
}
delay(0);
}
delay(200);
for(int k=0;k<10;k++)
{
for(i=0;i<160;i+=6)
{
for(j=0;j<25;j++)
{ c=*(p+160*j+i);
d=*(p+160*(j+1)+i);
*(p+160*(j+1)+i)=c;
c=d;
}
delay(0);
*(p+i)=c;
}
delay(0);
}
}
}
run this prog. & experience the matrix movie.......
#include
#include
#include
#include
void main()
{
char c,d;
int i,j;
char a[15]={' ','A','D',' ','I','T','Y',' ','A',' ','A','D',' ','I','
'};//here characters are taken as my name
//u can change it to any other characters as yr own name
char far* p;
p=(char far*)0xb0008000;// vga memory address
clrscr();
randomize();
while(!kbhit())
{
delay(0);
for(i=0;i<160;i=i+6)
{
for(int j=0;j<50;j++)
{ *(p+160*j+i+1)=2;
*(p+160*j+i)=a[random(15)];
delay(0);
}
delay(0);
}
delay(200);
for(int k=0;k<10;k++)
{
for(i=0;i<160;i+=6)
{
for(j=0;j<25;j++)
{ c=*(p+160*j+i);
d=*(p+160*(j+1)+i);
*(p+160*(j+1)+i)=c;
c=d;
}
delay(0);
*(p+i)=c;
}
delay(0);
}
}
}
run this prog. & experience the matrix movie.......
/* some interesting program -3*/
/*======================program for implementation of PAINT =======================*/
Code :
/* * * * * * * * *> PAINT 0.2 <* * * * ** /
AUTHOR : NIKHIL.K.R
Email : nikhilkr@hotmail.com
*/
/************************************HELP********************
1. USE LEFT BUTTON FOR SELECTING BRUSH-SIZE,COLOR,SHAPES
AND FREE-HAND DRAWING.
2. USE RIGHT BUTTON FOR DRAWING SHAPES
LAST MODIFICATION: 09/04/2005
/**********************************************************/
#include
#include
#include
#include
union REGS i,o;
int X,Y,COLOR=15,SIZE=0,CLEAR=0;
main()
{
int gd=DETECT,gm,maxx,maxy,x,y,button,prevx,prevy,errorcode;
char ch=99;
initgraph(&gd,&gm,"c:\tc\bgi");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
gotoxy(12,13);
printf("Graphics error: %s
", grapherrormsg(errorcode));
textcolor(RED + BLINK);
cprintf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
// introduction();
setbkcolor(0);
maxx=getmaxx();
maxy=getmaxy();
COLOR=8;
start();
setcolor(15);
settextstyle(3,1,4);
outtextxy(25,102,"nikhilkr@hotmail.com");
settextstyle(10,0,4);
outtextxy(170,10,"NIKHIL'S PAINT 0.2");
ohm();
setcolor(4);
rectangle(0,0,maxx-3,maxy);//outer box
rectangle(2,2,maxx-5,maxy-2);
begin:
setcolor(9);
AGAIN:
if(CLEAR)
{
cleardevice();
CLEAR=0;
setcolor(15);
settextstyle(3,1,4);
outtextxy(-75,17,"nikhilkr@hotmail.com");
settextstyle(10,0,4);
outtextxy(70,-75,"NIKHIL'S PAINT 0.2");
ohm();
setcolor(4);
rectangle(-100,-85,537,393);//outer box
rectangle(-98,-83,536,391);
}
setviewport(100,85,633,110,0);
menu();
if(initmouse()==0)
{
closegraph();
restorecrtmode();
printf("MOUSE DRIVER NOT LOADED");
exit(1);
}
restrictmouseptr(100,100,maxx-8,maxy-5);
showmouseptr();
while(!kbhit())
{
getmousepos(&button,&x,&y);
if((button & 1)==1)
{
hidemouseptr(); //hide mouse while drawing
menu();
prevx=x;
prevy=y;
while((button & 1)==1)
{
if(y>130 && prevy>130)//DRAW INSIDE WORK AREA
{
setcolor(COLOR);
if(SIZE)
{
setfillstyle(1,COLOR);
ellipse(x-100,y-85,0,360,SIZE,SIZE);
fillellipse(x-100,y-85,SIZE,SIZE);
}
else
line(prevx-100,prevy-85,x-100,y-85);
prevx=x;
prevy=y;
}
getmousepos(&button,&x,&y);
}
if(CLEAR)
goto AGAIN;
showmouseptr();
}
}
ch=getche();
goto begin;
}
tools(int x,int y,int colour,int io)// io => cursor inside/outside
{
int xx,yy;
setcolor(colour);
if((x>577 && x<631)&&(y>100 && y<110) && io)
{
settextstyle(7,0,1);
outtextxy(487,2,"QUIT");
}
else if(x>469 && x<593 && y>100 && y<110 && io)
{
settextstyle(11,0,1);
outtextxy(372,2," BRUSH SIZE");
}
else if(x>100 && x<469 && y>85 && y<110 && io)
rectangle(-2,-2,369,25);
else if(io==0)
{
settextstyle(11,0,1);
outtextxy(372,2," BRUSH SIZE");
settextstyle(7,0,1);
outtextxy(487,2,"QUIT");
setcolor(7);
rectangle(-2,-2,369,25);
}
return;
}
set_color()
{
int i,j,x=0;
setcolor(1);
for(i=15;i>=0;i--)
{
setcolor(15);
ellipse(x+12,13,0,360,11,11);
setfillstyle(1,i);
fillellipse(x+12,13,11,11);
x+=23;
}
return;
}
menu()
{
int maxx,maxy;
maxx=getmaxx();
maxy=getmaxy();
setcolor(8);
// setlinestyle(1,1,1);
rectangle(0,0,maxx-107,maxy-88);//inner box
setcolor(7);
rectangle(-3,-3,maxx-106,maxy-88);
gotoxy(31,8);
line(0,25,533,25);//toolbar line
line(369,25,369,0);//color divide line
line(478,25,478,0);//fill divide line
line(370,10,477,10);//partition line of size
rectangle(386,10,417,25);//brush size
rectangle(400,10,434,25);// " "
rectangle(448,10,465,25);// " "
settextstyle(11,0,1);
rectangle(145,25,202,45);//circle box line
rectangle(260,25,377,45);
outtextxy(90,32,"CIRCLE BOX LINE LINE PATTERN ");
outtextxy(382,32,"CLEAR");
line(0,45,531,45);
line(425,25,425,45); // x/y divide line
line(80,25,80,45);//TIME
setcolor(14);
settextstyle(11,0,1);
setcolor(13);
outtextxy(375,15,"0 1 2 3 4 5 6");
set_color();
return;
}
initmouse()
{
i.x.ax=0;
int86(0x33,&i,&o);
return(o.x.ax);
}
showmouseptr()
{
i.x.ax=1;
int86(0x33,&i,&o);
return;
}
hidemouseptr()
{
i.x.ax=2;
int86(0x33,&i,&o);
return;
}
restrictmouseptr(int x1,int y1,int x2,int y2)
{
i.x.ax=7;
i.x.cx=x1;
i.x.dx=x2;
int86(0x33,&i,&o);
i.x.ax=8;
i.x.cx=y1;
i.x.dx=y2;
int86(0x33,&i,&o);
return;
}
getmousepos(int *button,int *x,int *y)
{
struct time t;
i.x.ax=3;
int86(0x33,&i,&o);
*button=o.x.bx;
*x=o.x.cx;
*y=o.x.dx;
gotoxy(68,8);
printf("X:%d Y:%d",*x,*y);
gettime(&t);
gotoxy(14,8);
printf("%2d:%02d:%02d ",t.ti_hour, t.ti_min, t.ti_sec);
ohm();
if(*y<110)
tools(*x,*y,10,1);
else if(*y>110)
tools(*x,*y,6,0);//outside the tool-box
if((*button & 1)==1)
click(*x,*y);
return;
}
click(int x,int y)
{
if((x>100 && x<123)&&(y>90 && y<110))//COLOR OF BRUSH SELECTION
COLOR=15;
else if((x>123 && x<146)&&(y>90 && y<110))
COLOR=14;
else if((x>146 && x<169)&&(y>90 && y<110))
COLOR=13;
else if((x>169 && x<192)&&(y>90 && y<110))
COLOR=12;
else if((x>192 && x<215)&&(y>90 && y<110))
COLOR=11;
else if((x>215 && x<238)&&(y>90 && y<110))
COLOR=10;
else if((x>238 && x<261)&&(y>90 && y<110))
COLOR=9;
else if((x>261 && x<284)&&(y>90 && y<110))
COLOR=8;
else if((x>284 && x<307)&&(y>90 && y<110))
COLOR=7;
else if((x>307 && x<330)&&(y>90 && y<110))
COLOR=6;
else if((x>330 && x<353)&&(y>90 && y<110))
COLOR=5;
else if((x>353 && x<376)&&(y>90 && y<110))
COLOR=4;
else if((x>376 && x<399)&&(y>90 && y<110))
COLOR=3;
else if((x>399 && x<422)&&(y>90 && y<110))
COLOR=2;
else if((x>422 && x<444)&&(y>90 && y<110))
COLOR=1;
else if((x>444 && x<469)&&(y>90 && y<110))
COLOR=0;
else if((x>469 && x<486)&&(y>90 && y<110)) //BRUSH SIZE SELECTION
SIZE=0;
else if((x>486 && x<500)&&(y>90 && y<110))
SIZE=1;
else if((x>500 && x<517)&&(y>90 && y<110))
SIZE=2;
else if((x>517 && x<534)&&(y>90 && y<110))
SIZE=3;
else if((x>534 && x<548)&&(y>90 && y<110))
SIZE=4;
else if((x>548 && x<565)&&(y>90 && y<110))
SIZE=5;
else if((x>565 && x<577)&&(y>90 && y<110))
SIZE=6;
else if((x>180 && x<244)&&(y>112 && y<130))
draw(2,0);
else if((x>244 && x<302)&&(y>112 && y<130))
draw(1,0);
else if((x>302 && x<360)&&(y>112 && y<130))
draw(3,0);
else if((x>360 && x<477)&&(y>112 && y<130))
draw(3,1);
else if((x>477 && x<579)&&(y>112 && y<130))
CLEAR=1;
else if((x>579 && x<631)&&(y>90 && y<110)) //QUIT CLICKED
{
start();
exit(1);
}
return;
}
draw(int flag,int pat)
{
int button,x,y,sx,sy,x1,x2,y1,y2,tx,ty,lx,ly,prex,prey,rx,ry;
do
{
showmouseptr();
getmousepos(&button,&tx,&ty);
if((button && 2 ==2)&& ty>131 && tx>100)
{
hidemouseptr();
prex=sx=x=x1=x2=tx;
prey=sy=y=y1=y2=ty;
lx=x;
ly=y;
setcolor(COLOR);
rx=x2-x1;
ry=y2-y1;
if(flag==2)
ellipse(x1-100,y1-85,0,360,rx,ry);
else if(flag==1)
rectangle(x1-100,y1-85,x2-100,y2-85);
else if(flag==3 &&pat==0)
line(lx-100,ly-85,tx-100,ty-85);
getmousepos(&button,&tx,&ty);
while((button &2)==2)
{
if((x!=tx || y!=ty) && ty>130 && tx>100)
{
setcolor(0);
ry=y2-y1;
rx=x2-x1;
if(flag==2)
{
if(((y1-ry)>131 && (x1-rx)>100))
ellipse(x1-100,y1-85,0,360,rx,ry);
else
start();
}
else if(flag==1&& (y2-85)>25)
rectangle(x1-100,y1-85,x2-100,y2-85);
else if(flag==3)
line(lx-100,ly-85,tx-100,ty-85);
x=tx;
y=ty;
if(x {
x1=x;
x2=sx;
}
else
{
x1=sx;
x2=x;
}
if(y {
y1=y;
y2=sy;
}
else
{
y1=sy;
y2=y;
}
setcolor(COLOR);
ry=y2-y1;
rx=x2-x1;
if(flag==2)
{
if(((y1-ry)>131 && (x1-rx)>100))
ellipse(x1-100,y1-85,0,360,rx,ry);
else
{
settextstyle(11,0,1);
setcolor(9);
outtextxy(430,52,"OUT OF RANGE");
start();
delay(800);
setcolor(0);
outtextxy(430,52,"OUT OF RANGE");
}
}
else if(flag==1)
rectangle(x1-100,y1-85,x2-100,y2-85);
else if(flag==3 &&pat==0)
{
line(lx-100,ly-85,x-100,y-85);
setcolor(0);
line(lx-100,ly-85,prex-100,prey-85);
prex=tx;
prey=ty;
}
else if(flag==3 && pat==1)
line(lx-100,ly-85,x-100,y-85);
}
getmousepos(&button,&tx,&ty);
}
showmouseptr();
if(flag==3)
{
setcolor(COLOR);
line(lx-100,ly-85,x-100,y-85);
}
}
}
while((button & 1)!=1);
return;
}
introduction()
{
char a[10]="MATRIX";
int i;
setbkcolor(1);
gotoxy(35,13);
delay(1400);
for(i=0;i<6;i++)
{
delay(400);
printf("%c ",a[i]);
sound(5000);
delay(50);
nosound();
}
setcolor(10);
line(200,210,450,210);
sound(8000);
delay(400);
nosound();
cleardevice();
setcolor(4);
settextstyle(8,0,3);
outtextxy(200,200,"PRESS ANY KEY...");
getch();
cleardevice();
return;
}
start()
{
sound(2550);
delay(100);
nosound();
return;
}
ohm()
{
setfillstyle(1,COLOR);
fillellipse(-40,-45,45,15);
setcolor(COLOR+2);
settextstyle(8,0,3);
outtextxy(-64,-62,"HCL");
return;
}
Code :
/* * * * * * * * *> PAINT 0.2 <* * * * ** /
AUTHOR : NIKHIL.K.R
Email : nikhilkr@hotmail.com
*/
/************************************HELP********************
1. USE LEFT BUTTON FOR SELECTING BRUSH-SIZE,COLOR,SHAPES
AND FREE-HAND DRAWING.
2. USE RIGHT BUTTON FOR DRAWING SHAPES
LAST MODIFICATION: 09/04/2005
/**********************************************************/
#include
#include
#include
#include
union REGS i,o;
int X,Y,COLOR=15,SIZE=0,CLEAR=0;
main()
{
int gd=DETECT,gm,maxx,maxy,x,y,button,prevx,prevy,errorcode;
char ch=99;
initgraph(&gd,&gm,"c:\tc\bgi");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
gotoxy(12,13);
printf("Graphics error: %s
", grapherrormsg(errorcode));
textcolor(RED + BLINK);
cprintf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
// introduction();
setbkcolor(0);
maxx=getmaxx();
maxy=getmaxy();
COLOR=8;
start();
setcolor(15);
settextstyle(3,1,4);
outtextxy(25,102,"nikhilkr@hotmail.com");
settextstyle(10,0,4);
outtextxy(170,10,"NIKHIL'S PAINT 0.2");
ohm();
setcolor(4);
rectangle(0,0,maxx-3,maxy);//outer box
rectangle(2,2,maxx-5,maxy-2);
begin:
setcolor(9);
AGAIN:
if(CLEAR)
{
cleardevice();
CLEAR=0;
setcolor(15);
settextstyle(3,1,4);
outtextxy(-75,17,"nikhilkr@hotmail.com");
settextstyle(10,0,4);
outtextxy(70,-75,"NIKHIL'S PAINT 0.2");
ohm();
setcolor(4);
rectangle(-100,-85,537,393);//outer box
rectangle(-98,-83,536,391);
}
setviewport(100,85,633,110,0);
menu();
if(initmouse()==0)
{
closegraph();
restorecrtmode();
printf("MOUSE DRIVER NOT LOADED");
exit(1);
}
restrictmouseptr(100,100,maxx-8,maxy-5);
showmouseptr();
while(!kbhit())
{
getmousepos(&button,&x,&y);
if((button & 1)==1)
{
hidemouseptr(); //hide mouse while drawing
menu();
prevx=x;
prevy=y;
while((button & 1)==1)
{
if(y>130 && prevy>130)//DRAW INSIDE WORK AREA
{
setcolor(COLOR);
if(SIZE)
{
setfillstyle(1,COLOR);
ellipse(x-100,y-85,0,360,SIZE,SIZE);
fillellipse(x-100,y-85,SIZE,SIZE);
}
else
line(prevx-100,prevy-85,x-100,y-85);
prevx=x;
prevy=y;
}
getmousepos(&button,&x,&y);
}
if(CLEAR)
goto AGAIN;
showmouseptr();
}
}
ch=getche();
goto begin;
}
tools(int x,int y,int colour,int io)// io => cursor inside/outside
{
int xx,yy;
setcolor(colour);
if((x>577 && x<631)&&(y>100 && y<110) && io)
{
settextstyle(7,0,1);
outtextxy(487,2,"QUIT");
}
else if(x>469 && x<593 && y>100 && y<110 && io)
{
settextstyle(11,0,1);
outtextxy(372,2," BRUSH SIZE");
}
else if(x>100 && x<469 && y>85 && y<110 && io)
rectangle(-2,-2,369,25);
else if(io==0)
{
settextstyle(11,0,1);
outtextxy(372,2," BRUSH SIZE");
settextstyle(7,0,1);
outtextxy(487,2,"QUIT");
setcolor(7);
rectangle(-2,-2,369,25);
}
return;
}
set_color()
{
int i,j,x=0;
setcolor(1);
for(i=15;i>=0;i--)
{
setcolor(15);
ellipse(x+12,13,0,360,11,11);
setfillstyle(1,i);
fillellipse(x+12,13,11,11);
x+=23;
}
return;
}
menu()
{
int maxx,maxy;
maxx=getmaxx();
maxy=getmaxy();
setcolor(8);
// setlinestyle(1,1,1);
rectangle(0,0,maxx-107,maxy-88);//inner box
setcolor(7);
rectangle(-3,-3,maxx-106,maxy-88);
gotoxy(31,8);
line(0,25,533,25);//toolbar line
line(369,25,369,0);//color divide line
line(478,25,478,0);//fill divide line
line(370,10,477,10);//partition line of size
rectangle(386,10,417,25);//brush size
rectangle(400,10,434,25);// " "
rectangle(448,10,465,25);// " "
settextstyle(11,0,1);
rectangle(145,25,202,45);//circle box line
rectangle(260,25,377,45);
outtextxy(90,32,"CIRCLE BOX LINE LINE PATTERN ");
outtextxy(382,32,"CLEAR");
line(0,45,531,45);
line(425,25,425,45); // x/y divide line
line(80,25,80,45);//TIME
setcolor(14);
settextstyle(11,0,1);
setcolor(13);
outtextxy(375,15,"0 1 2 3 4 5 6");
set_color();
return;
}
initmouse()
{
i.x.ax=0;
int86(0x33,&i,&o);
return(o.x.ax);
}
showmouseptr()
{
i.x.ax=1;
int86(0x33,&i,&o);
return;
}
hidemouseptr()
{
i.x.ax=2;
int86(0x33,&i,&o);
return;
}
restrictmouseptr(int x1,int y1,int x2,int y2)
{
i.x.ax=7;
i.x.cx=x1;
i.x.dx=x2;
int86(0x33,&i,&o);
i.x.ax=8;
i.x.cx=y1;
i.x.dx=y2;
int86(0x33,&i,&o);
return;
}
getmousepos(int *button,int *x,int *y)
{
struct time t;
i.x.ax=3;
int86(0x33,&i,&o);
*button=o.x.bx;
*x=o.x.cx;
*y=o.x.dx;
gotoxy(68,8);
printf("X:%d Y:%d",*x,*y);
gettime(&t);
gotoxy(14,8);
printf("%2d:%02d:%02d ",t.ti_hour, t.ti_min, t.ti_sec);
ohm();
if(*y<110)
tools(*x,*y,10,1);
else if(*y>110)
tools(*x,*y,6,0);//outside the tool-box
if((*button & 1)==1)
click(*x,*y);
return;
}
click(int x,int y)
{
if((x>100 && x<123)&&(y>90 && y<110))//COLOR OF BRUSH SELECTION
COLOR=15;
else if((x>123 && x<146)&&(y>90 && y<110))
COLOR=14;
else if((x>146 && x<169)&&(y>90 && y<110))
COLOR=13;
else if((x>169 && x<192)&&(y>90 && y<110))
COLOR=12;
else if((x>192 && x<215)&&(y>90 && y<110))
COLOR=11;
else if((x>215 && x<238)&&(y>90 && y<110))
COLOR=10;
else if((x>238 && x<261)&&(y>90 && y<110))
COLOR=9;
else if((x>261 && x<284)&&(y>90 && y<110))
COLOR=8;
else if((x>284 && x<307)&&(y>90 && y<110))
COLOR=7;
else if((x>307 && x<330)&&(y>90 && y<110))
COLOR=6;
else if((x>330 && x<353)&&(y>90 && y<110))
COLOR=5;
else if((x>353 && x<376)&&(y>90 && y<110))
COLOR=4;
else if((x>376 && x<399)&&(y>90 && y<110))
COLOR=3;
else if((x>399 && x<422)&&(y>90 && y<110))
COLOR=2;
else if((x>422 && x<444)&&(y>90 && y<110))
COLOR=1;
else if((x>444 && x<469)&&(y>90 && y<110))
COLOR=0;
else if((x>469 && x<486)&&(y>90 && y<110)) //BRUSH SIZE SELECTION
SIZE=0;
else if((x>486 && x<500)&&(y>90 && y<110))
SIZE=1;
else if((x>500 && x<517)&&(y>90 && y<110))
SIZE=2;
else if((x>517 && x<534)&&(y>90 && y<110))
SIZE=3;
else if((x>534 && x<548)&&(y>90 && y<110))
SIZE=4;
else if((x>548 && x<565)&&(y>90 && y<110))
SIZE=5;
else if((x>565 && x<577)&&(y>90 && y<110))
SIZE=6;
else if((x>180 && x<244)&&(y>112 && y<130))
draw(2,0);
else if((x>244 && x<302)&&(y>112 && y<130))
draw(1,0);
else if((x>302 && x<360)&&(y>112 && y<130))
draw(3,0);
else if((x>360 && x<477)&&(y>112 && y<130))
draw(3,1);
else if((x>477 && x<579)&&(y>112 && y<130))
CLEAR=1;
else if((x>579 && x<631)&&(y>90 && y<110)) //QUIT CLICKED
{
start();
exit(1);
}
return;
}
draw(int flag,int pat)
{
int button,x,y,sx,sy,x1,x2,y1,y2,tx,ty,lx,ly,prex,prey,rx,ry;
do
{
showmouseptr();
getmousepos(&button,&tx,&ty);
if((button && 2 ==2)&& ty>131 && tx>100)
{
hidemouseptr();
prex=sx=x=x1=x2=tx;
prey=sy=y=y1=y2=ty;
lx=x;
ly=y;
setcolor(COLOR);
rx=x2-x1;
ry=y2-y1;
if(flag==2)
ellipse(x1-100,y1-85,0,360,rx,ry);
else if(flag==1)
rectangle(x1-100,y1-85,x2-100,y2-85);
else if(flag==3 &&pat==0)
line(lx-100,ly-85,tx-100,ty-85);
getmousepos(&button,&tx,&ty);
while((button &2)==2)
{
if((x!=tx || y!=ty) && ty>130 && tx>100)
{
setcolor(0);
ry=y2-y1;
rx=x2-x1;
if(flag==2)
{
if(((y1-ry)>131 && (x1-rx)>100))
ellipse(x1-100,y1-85,0,360,rx,ry);
else
start();
}
else if(flag==1&& (y2-85)>25)
rectangle(x1-100,y1-85,x2-100,y2-85);
else if(flag==3)
line(lx-100,ly-85,tx-100,ty-85);
x=tx;
y=ty;
if(x
x1=x;
x2=sx;
}
else
{
x1=sx;
x2=x;
}
if(y
y1=y;
y2=sy;
}
else
{
y1=sy;
y2=y;
}
setcolor(COLOR);
ry=y2-y1;
rx=x2-x1;
if(flag==2)
{
if(((y1-ry)>131 && (x1-rx)>100))
ellipse(x1-100,y1-85,0,360,rx,ry);
else
{
settextstyle(11,0,1);
setcolor(9);
outtextxy(430,52,"OUT OF RANGE");
start();
delay(800);
setcolor(0);
outtextxy(430,52,"OUT OF RANGE");
}
}
else if(flag==1)
rectangle(x1-100,y1-85,x2-100,y2-85);
else if(flag==3 &&pat==0)
{
line(lx-100,ly-85,x-100,y-85);
setcolor(0);
line(lx-100,ly-85,prex-100,prey-85);
prex=tx;
prey=ty;
}
else if(flag==3 && pat==1)
line(lx-100,ly-85,x-100,y-85);
}
getmousepos(&button,&tx,&ty);
}
showmouseptr();
if(flag==3)
{
setcolor(COLOR);
line(lx-100,ly-85,x-100,y-85);
}
}
}
while((button & 1)!=1);
return;
}
introduction()
{
char a[10]="MATRIX";
int i;
setbkcolor(1);
gotoxy(35,13);
delay(1400);
for(i=0;i<6;i++)
{
delay(400);
printf("%c ",a[i]);
sound(5000);
delay(50);
nosound();
}
setcolor(10);
line(200,210,450,210);
sound(8000);
delay(400);
nosound();
cleardevice();
setcolor(4);
settextstyle(8,0,3);
outtextxy(200,200,"PRESS ANY KEY...");
getch();
cleardevice();
return;
}
start()
{
sound(2550);
delay(100);
nosound();
return;
}
ohm()
{
setfillstyle(1,COLOR);
fillellipse(-40,-45,45,15);
setcolor(COLOR+2);
settextstyle(8,0,3);
outtextxy(-64,-62,"HCL");
return;
}
/* some interesting program -2*/
/*===================program to geerate snake game for fun=========================*/
#include
#include
#include
#include
#include
#include
check();
end();
win();
int m[500],n[500],con=20,TEMP;
clock_t start,stop;
void main(void)
{
int gd=DETECT,gm,ch,maxx,maxy,x=13,y=14,p,q,spd=100;
int a=0,i=0,j,t,temp;
initgraph(&gd,&gm,"..\bgi");
setcolor(WHITE);
settextstyle(3,0,6);
outtextxy(200,2," SNAKE 2 BY RAJESH ");
settextstyle(6,0,2);
outtextxy(20,80," Use Arrow Keys To Direct The Snake ");
outtextxy(20,140," Avoid The Head Of Snake Not To Hit Any Part Of
Snake");
outtextxy(20,160," Pick The Beats Untill You Win The Game ");
outtextxy(20,200," Press 'Esc' Anytime To Exit ");
outtextxy(20,220," Press Any Key To Continue ");
outtextxy(20,220," DONT FORGET TO GIVE U R VALUABLE OPINION ");
ch=getch();
if(ch==27) exit(0);
cleardevice();
maxx=getmaxx();
maxy=getmaxy();
randomize();
p=random(maxx);
temp=p%13;
p=p-temp;
q=random(maxy);
temp=q%14;
q=q-temp;
start=clock();
while(1)
{
setcolor(WHITE);
setfillstyle(SOLID_FILL,con+5);
circle(p,q,5);
floodfill(p,q,WHITE);
if( kbhit() )
{
ch=getch(); if(ch==0) ch=getch();
if(ch==72&& a!=2) a=1;
if(ch==80&& a!=1) a=2;
if(ch==75&& a!=4) a=3;
if(ch==77&& a!=3) a=4;
}
else
{
if(ch==27
) break;
}
if(i<20){
m[i]=x;
n[i]=y;
i++;
}
if(i>=20)
{
for(j=con;j>=0;j--){
m[1+j]=m[j];
n[1+j]=n[j];
}
m[0]=x;
n[0]=y;
setcolor(WHITE);
setfillstyle(SOLID_FILL,con);
circle(m[0],n[0],8);
floodfill(m[0],n[0],WHITE);
setcolor(WHITE);
for(j=1;j setfillstyle(SOLID_FILL,con+j%3);
circle(m[j],n[j],5);
floodfill(m[j],n[j],WHITE);
}
delay(spd);
setcolor(BLACK);
setfillstyle(SOLID_FILL,BLACK);
circle(m[0],n[0],8);
floodfill(m[0],n[0],BLACK);
setcolor(BLACK);
setfillstyle(SOLID_FILL,BLACK);
circle(m[j],n[j],5);
floodfill(m[j],n[j],BLACK);
}
stop=clock();
t=(stop-start)/CLK_TCK;
printf(" TIME %d sec ",t);
printf("SCORE %d
",con-5);
check();
if(x==p&&y==q) { con=con+5; if(spd>=5) spd=spd-5; else spd=5;
if(con>490) win();
p=random(maxx); temp=p%13; p=p-temp;
q=random(maxy); temp=q%14; q=q-temp;
}
if(a==1) y = y-14; if(y<0) { temp=maxy%14;y=maxy-temp;}
if(a==2) y = y+14; if(y>maxy) y=0;
if(a==3) x = x-13; if(x<0) { temp=maxx%13;x=maxx-temp;}
if(a==4) x = x+13; if(x>maxx) x=0;
if(a==0){ y = y+14 ; x=x+13; }
}
}
check(){
int a;
for(a=1;a
if(m[0]==m[a] && n[0]==n[a]) end();
else continue;
}
end()
{
int j,i;
setcolor(WHITE);
for(i=0;i<5;i++){
delay(500);
cleardevice();
delay(500);
for(j=0;j<=con;j++){
setfillstyle(SOLID_FILL,RED);
circle(m[j],n[j],5);
floodfill(m[j],n[j],WHITE);
}
}
settextstyle(3,0,4);
outtextxy(150,150," GAME OVER ");
getch();
getch();
exit(0);
}
win()
{
int j,i;
setcolor(WHITE);
for(i=0;i<5;i++){
for(j=0;j<=con;j++){
setfillstyle(SOLID_FILL,con);
circle(m[j],n[j],5);
floodfill(m[j],n[j],WHITE);
}
delay(500);
cleardevice();
delay(500);
}
settextstyle(3,0,4);
outtextxy(210,320," YOU WIN ");
getch();
exit(0);
}
#include
#include
#include
#include
#include
#include
check();
end();
win();
int m[500],n[500],con=20,TEMP;
clock_t start,stop;
void main(void)
{
int gd=DETECT,gm,ch,maxx,maxy,x=13,y=14,p,q,spd=100;
int a=0,i=0,j,t,temp;
initgraph(&gd,&gm,"..\bgi");
setcolor(WHITE);
settextstyle(3,0,6);
outtextxy(200,2," SNAKE 2 BY RAJESH ");
settextstyle(6,0,2);
outtextxy(20,80," Use Arrow Keys To Direct The Snake ");
outtextxy(20,140," Avoid The Head Of Snake Not To Hit Any Part Of
Snake");
outtextxy(20,160," Pick The Beats Untill You Win The Game ");
outtextxy(20,200," Press 'Esc' Anytime To Exit ");
outtextxy(20,220," Press Any Key To Continue ");
outtextxy(20,220," DONT FORGET TO GIVE U R VALUABLE OPINION ");
ch=getch();
if(ch==27) exit(0);
cleardevice();
maxx=getmaxx();
maxy=getmaxy();
randomize();
p=random(maxx);
temp=p%13;
p=p-temp;
q=random(maxy);
temp=q%14;
q=q-temp;
start=clock();
while(1)
{
setcolor(WHITE);
setfillstyle(SOLID_FILL,con+5);
circle(p,q,5);
floodfill(p,q,WHITE);
if( kbhit() )
{
ch=getch(); if(ch==0) ch=getch();
if(ch==72&& a!=2) a=1;
if(ch==80&& a!=1) a=2;
if(ch==75&& a!=4) a=3;
if(ch==77&& a!=3) a=4;
}
else
{
if(ch==27
) break;
}
if(i<20){
m[i]=x;
n[i]=y;
i++;
}
if(i>=20)
{
for(j=con;j>=0;j--){
m[1+j]=m[j];
n[1+j]=n[j];
}
m[0]=x;
n[0]=y;
setcolor(WHITE);
setfillstyle(SOLID_FILL,con);
circle(m[0],n[0],8);
floodfill(m[0],n[0],WHITE);
setcolor(WHITE);
for(j=1;j
circle(m[j],n[j],5);
floodfill(m[j],n[j],WHITE);
}
delay(spd);
setcolor(BLACK);
setfillstyle(SOLID_FILL,BLACK);
circle(m[0],n[0],8);
floodfill(m[0],n[0],BLACK);
setcolor(BLACK);
setfillstyle(SOLID_FILL,BLACK);
circle(m[j],n[j],5);
floodfill(m[j],n[j],BLACK);
}
stop=clock();
t=(stop-start)/CLK_TCK;
printf(" TIME %d sec ",t);
printf("SCORE %d
",con-5);
check();
if(x==p&&y==q) { con=con+5; if(spd>=5) spd=spd-5; else spd=5;
if(con>490) win();
p=random(maxx); temp=p%13; p=p-temp;
q=random(maxy); temp=q%14; q=q-temp;
}
if(a==1) y = y-14; if(y<0) { temp=maxy%14;y=maxy-temp;}
if(a==2) y = y+14; if(y>maxy) y=0;
if(a==3) x = x-13; if(x<0) { temp=maxx%13;x=maxx-temp;}
if(a==4) x = x+13; if(x>maxx) x=0;
if(a==0){ y = y+14 ; x=x+13; }
}
}
check(){
int a;
for(a=1;a
if(m[0]==m[a] && n[0]==n[a]) end();
else continue;
}
end()
{
int j,i;
setcolor(WHITE);
for(i=0;i<5;i++){
delay(500);
cleardevice();
delay(500);
for(j=0;j<=con;j++){
setfillstyle(SOLID_FILL,RED);
circle(m[j],n[j],5);
floodfill(m[j],n[j],WHITE);
}
}
settextstyle(3,0,4);
outtextxy(150,150," GAME OVER ");
getch();
getch();
exit(0);
}
win()
{
int j,i;
setcolor(WHITE);
for(i=0;i<5;i++){
for(j=0;j<=con;j++){
setfillstyle(SOLID_FILL,con);
circle(m[j],n[j],5);
floodfill(m[j],n[j],WHITE);
}
delay(500);
cleardevice();
delay(500);
}
settextstyle(3,0,4);
outtextxy(210,320," YOU WIN ");
getch();
exit(0);
}
/* some interesting program -1*/
here i show u a program which r downloaded from net ,u get interesting thing which r not know to u..
only run it & doooom u get best o/p...
*************************************************************************************
/* GAME OF NUMBERS IMPLEMENTATION */
# include
# include
# include
# include
# define UP_ARROW 72 /* Scan code of up arrow */
# define DOWN_ARROW 80 /* Scan code of down arrow */
# define LEFT_ARROW 75 /* Scan code of left arrow */
# define RIGHT_ARROW 77 /* Scan code of right arrow */
# define ESC 1 /* Scan code of escape key */
int a[4][4]={ /* Array to store the numbers */
{4,6,12,1},
{2,8,10,14},
{3,7,13,9},
{5,11,15,0}
};
int r=3; /* Row of the array */
int c=3; /* Coloumn of the array */
int moves=0; /* To count no. of moves */
/* Prototype Declaration */
void Display(void); /* Prototype of display function */
void Boxes(void); /* Prototype of boxes function */
void Game(void); /* Prototype of game function */
void Esc(void); /* Prototype of escape function */
int Getkey(void); /* Prototype of getkey function */
void Install(void); /* Prototype of install function */
void Rules(void); /* Prototype of rules function */
void Win(void); /* Prototype of win function */
/* Main Game Function */
void Game(void)
{
int ch;
int temp;
Boxes();
Display();
while(1)
{
ch=Getkey();
switch(ch)
{
case DOWN_ARROW :
if(r==0)
{
printf("a");
break;
}
temp=a[r][c];
a[r][c]=a[r-1][c];
a[r-1][c]=temp;
r--;
moves++;
Display();
break;
case UP_ARROW :
if(r==3)
{
printf("a");
break;
}
temp=a[r][c];
a[r][c]=a[r+1][c];
a[r+1][c]=temp;
r++;
moves++;
Display();
break;
case LEFT_ARROW :
if(c==3)
{
printf("a");
break;
}
temp=a[r][c];
a[r][c]=a[r][c+1];
a[r][c+1]=temp;
c++;
moves++;
Display();
break;
case RIGHT_ARROW :
if(c==0)
{
printf("a");
break;
}
temp=a[r][c];
a[r][c]=a[r][c-1];
a[r][c-1]=temp;
c--;
moves++;
Display();
break;
case ESC :
Esc();
break;
default :
break;
}
}
}
/* Escape Function */
void Esc(void)
{
Win();
gotoxy(27,22);
textcolor(LIGHTGREEN);
cprintf("No. of moves = %d",moves);
getch();
exit(0);
}
/* Display Function */
void Display(void)
{
int r1=9,c1=30;
int i,j;
textcolor(MAGENTA);
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
if(a[i][j]==0)
{
gotoxy(c1,r1);
cprintf(" ");
}
else
{
gotoxy(c1,r1);
cprintf("%d",a[i][j]);
}
c1=c1+3;
}
c1=30;
r1=r1+2;
}
}
/* Function To Draw Boxes */
void Boxes(void)
{
int i,j;
gotoxy(26,3);
textcolor(MAGENTA);
cprintf("GAME OF THE CENTURY");
textcolor(YELLOW);
for(i=8;i<=16;i=i+2)
{
for(j=29;j<=41;j++)
{
gotoxy(j,i);
cprintf("%c",196);
}
}
for(i=29;i<=42;i=i+3)
{
for(j=8;j<=16;j++)
{
gotoxy(i,j);
cprintf("%c",179);
}
}
gotoxy(29,8);
cprintf("%c",218);
gotoxy(29,16);
cprintf("%c",192);
gotoxy(41,8);
cprintf("%c",191);
gotoxy(41,16);
cprintf("%c",217);
for(i=32;i<=38;i=i+3)
{
gotoxy(i,8);
cprintf("%c",194);
}
for(i=32;i<=38;i=i+3)
{
gotoxy(i,16);
cprintf("%c",193);
}
for(i=10;i<=14;i=i+2)
{
for(j=32;j<=38;j=j+3)
{
gotoxy(j,i);
cprintf("%c",197);
}
}
for(i=10;i<=14;i=i+2)
{
gotoxy(29,i);
cprintf("%c",195);
}
for(i=10;i<=14;i=i+2)
{
gotoxy(41,i);
cprintf("%c",180);
}
}
/* Function To Get The Scan Code of Key */
int Getkey(void)
{
union REGS i,o;
while(!kbhit());
i.h.ah=0;
int86(22,&i,&o);
return(o.h.ah);
}
/* Install Menu Function */
void Install(void)
{
int i,j;
int c=11,r=19;
int time=0;
gotoxy(32,13);
textcolor(BROWN);
cprintf("INSTALLING MENU");
textcolor(YELLOW);
gotoxy(1,19);
cprintf("Installing");
for(i=20;i<=22;i=i+2)
{
for(j=1;j<=80;j++)
{
gotoxy(j,i);
cprintf("%c",196);
}
}
for(i=20;i<=22;i++)
{
gotoxy(1,i);
cprintf("%c",179);
}
for(i=20;i<=22;i++)
{
gotoxy(80,i);
cprintf("%c",179);
}
gotoxy(1,20);
cprintf("%c",218);
gotoxy(1,22);
cprintf("%c",192);
gotoxy(80,20);
cprintf("%c",191);
gotoxy(80,22);
cprintf("%c",217);
for(i=2;i<=79;i++)
{
gotoxy(i,21);
printf("%c",176);
}
for(i=2;i<=79;i++)
{
gotoxy(i,21);
delay(500);
textcolor(BLUE);
cprintf("%c",219);
gotoxy(67,19);
printf(" ");
if(c==15)
{
for(j=11;j<=15;j++)
{
gotoxy(j,19);
printf(" ");
}
c=11;
}
gotoxy(c,r);
textcolor(YELLOW);
cprintf(".");
c++;
gotoxy(67,19);
textcolor(YELLOW);
cprintf("%d% Completed",time);
if(time<=60)
{
time++;
}
else if(time<=71)
time=time+2;
else
time=time+3;
if(i==78)
time=time-3;
}
}
/* Rules Menu Function */
void Rules(void)
{
int i;
textcolor(LIGHTCYAN);
gotoxy(39,5);
cprintf("RULES");
textcolor(GREEN);
gotoxy(18,7);
cprintf("1. Your aim is to arrange numbers in ascending order");
gotoxy(18,9);
cprintf("2. The player with minimum no. of moves wins the game");
textcolor(LIGHTGRAY);
for(i=17;i<=71;i++)
{
gotoxy(i,6);
cprintf("%c",196);
}
for(i=17;i<=71;i++)
{
gotoxy(i,10);
cprintf("%c",196);
}
for(i=6;i<=10;i++)
{
gotoxy(17,i);
cprintf("%c",179);
}
for(i=6;i<=10;i++)
{
gotoxy(71,i);
cprintf("%c",179);
}
gotoxy(17,6);
cprintf("%c",218);
gotoxy(17,10);
cprintf("%c",192);
gotoxy(71,6);
cprintf("%c",191);
gotoxy(71,10);
cprintf("%c",217);
}
/* Function To Check For Win */
void Win(void)
{
int i,j,pos;
int flag=1;
int arr[20];
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
pos=i*4+j;
arr[pos]=a[i][j];
}
}
for(i=0;i {
if(arr[i]>arr[i+1])
{
flag=0;
break;
}
}
if(flag==1)
{
gotoxy(30,21);
printf("YOU WIN");
}
}
/* The Main Function */
void main(void)
{
clrscr();
Install();
sleep(1);
clrscr();
Rules();
getch();
clrscr();
Game();
getch();
}
*************************************************************************************
=====================================================================================
/****************************************************************************
*****************************************************************************
"THE SCHEDULER"
THE PROJECT IS MADE FOR THE EXECUTION OF TIME TABLES. A COMMON PROBLEM ARISES THAT A COMMON ROOM OR A COMMON TEACHER IS SHARED BY TWO OR MORE CLASSES. THIS PROJECT IS TO SOLVE PROBLEMS LIKE THIS.
*****************************************************************************
****************************************************************************/
/***************************************************************************/
/*******************************HEADER FILES********************************/
/***************************************************************************/
#include
#include
#include
#include
/*******************************LETS START*********************************/
/***************************THE WELCOME SCREEN*****************************/
void first()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
setcolor(GREEN);
settextstyle(4,0,8);
outtextxy(200,50,"TIME");
setcolor(YELLOW);
settextstyle(4,0,8);
outtextxy(100,190,"SCHEDULER");
settextstyle(1,0,1);
setcolor(RED);
outtextxy(480,350,"Made By:");
setcolor(BLUE);
outtextxy(480,370,"Atiq Anwar");
getch();
restorecrtmode();
}
/******************************WORK BEGINS********************************/
/**********************FUNCTION FOR THE 'MAIN MENU'***********************/
char file()
{
int gdriver=DETECT, gmod;
char i;
initgraph(&gdriver,&gmod,"c:\\tc\\bgi");
setcolor(RED);
rectangle(170,85,430,385);
rectangle(175,90, 425,380);
setcolor(GREEN);
settextstyle(7,0,4);
outtextxy(130,45,"TIME TABLE MANAGER");
settextstyle(7,0,3);
setcolor(YELLOW);
outtextxy(260,95,"MENU");
settextstyle(0,0,0);
setcolor(MAGENTA);
outtextxy(200,145,"1>>ENTER TEACHER.");
outtextxy(200,170,"2>>ENTER ROOM.");
outtextxy(200,195,"3>>REMOVE TEACHER.");
outtextxy(200,220,"4>>REMOVE ROOM.");
outtextxy(200,245,"5>>VIEW TEACHER.");
outtextxy(200,270,"6>>VIEW ROOM.");
outtextxy(200,295,"7>>CREATE TIME TABLE.");
outtextxy(200,320,"8>>VIEW TIME TABLE.");
outtextxy(200,343,"0>>EXIT.");
setcolor(GREEN+BLINK);
outtextxy(200,360,"ENTER YOUR CHOICE:");
i=getche();
restorecrtmode();
return (i);
}
/********************************OUTLINES********************************/
/************************THE COMMON DISPLAY FRAME************************/
void frame()
{
int x,y,i,j;
clrscr();
x=0;
y=0;
for(i=0;i<78;i++)
{
gotoxy(x,y);
textcolor(YELLOW);
cprintf("%c",205);
x++;
}
x=0;
y=25;
for(i=0;i<80;i++)
{
gotoxy(x,y);
textcolor(YELLOW);
cprintf("%c",205);
x++;
}
x=1;
y=1;
for(i=0;i<25;i++)
{
gotoxy(x,y);
textcolor(YELLOW);
cprintf("%c",186);
y++;
}
x=79;
y=1;
for(i=0;i<25;i++)
{
gotoxy(x,y);
textcolor(YELLOW);
cprintf("%c",186);
y++;
}
gotoxy(1,1);
cprintf("%c",201);
gotoxy(1,25);
cprintf("%c",200);
gotoxy(79,1);
cprintf("%c",187);
gotoxy(79,25);
cprintf("%c",188);
}
/*****************************TEACHER COMES*******************************/
/**********************OUTPUT FOR TEACHER'S DATAS**************************/
void teacher()
{
int i;
struct teacher
{
char nam[25],sub[15],room[15];
}t;
FILE *fp;
fp=fopen("teacher.txt","r");
if(fp==NULL)
{
gotoxy(30,12);
textcolor(RED+BLINK);
cprintf("Cannot Open File!!");
exit();
}
frame();
textcolor(GREEN);
gotoxy(5,2);
cprintf("Name");
gotoxy(35,2);
cprintf("Subject");
gotoxy(68,2);
cprintf("Choice");
for(i=3;i<=77;i++)
{
textcolor(YELLOW);
gotoxy(i,3);
cprintf("-");
}
i=4;
while(fscanf(fp,"%s %s %s ",t.nam,t.sub,t.room)!=EOF)
{
gotoxy(5,i);
printf("%s",t.nam);
gotoxy(35,i);
printf("%s",t.sub);
gotoxy(68,i);
printf("%s",t.room);
i++;
if(i > 20)
{
clrscr();
frame();
textcolor(GREEN);
gotoxy(5,2);
cprintf("Name");
gotoxy(35,2);
cprintf("Subject");
gotoxy(68,2);
cprintf("Choice");
for(i=3;i<=77;i++)
{
textcolor(YELLOW);
gotoxy(i,3);
cprintf("-");
}
i=4;
}
}
fclose(fp);
}
/*******************************ROOM OPENS********************************/
/************************OUTPUT FOR ROOM'S DATAS***************************/
void room()
{
struct room
{
int cap;
char rt[20],rn[15];
}r;
int i;
FILE *fp;
clrscr();
fp=fopen("room.txt","r");
if(fp==NULL)
{
gotoxy(30,12);
textcolor(RED+BLINK);
cprintf("Cannot Open File!!");
exit();
}
frame();
textcolor(GREEN);
gotoxy(5,2);
cprintf("Room");
gotoxy(35,2);
cprintf("Room Code");
gotoxy(68,2);
cprintf("Capacity");
for(i=3;i<=77;i++)
{
textcolor(YELLOW);
gotoxy(i,3);
cprintf("-");
}
i=4;
while(fscanf(fp,"%s %s %d",r.rt,r.rn,&r.cap)!=EOF)
{
gotoxy(5,i);
printf("%s",r.rt);
gotoxy(35,i);
printf("%s",r.rn);
gotoxy(68,i);
printf("%d",r.cap);
i++;
if(i > 20)
{
getch();
clrscr();
frame();
textcolor(GREEN);
gotoxy(5,2);
cprintf("Room");
gotoxy(35,2);
cprintf("Room Code");
gotoxy(68,2);
cprintf("Capacity");
for(i=3;i<=77;i++)
{
textcolor(YELLOW);
gotoxy(i,3);
cprintf("-");
}
i=4;
}
}
fclose(fp);
}
/******************************MAIN FRAME*********************************/
/*************************THE TIME TABLE GRID*****************************/
void frame1()
{
int x,y,i,j,h;
clrscr();
frame();
for(y=4;y<23;y+=3)
{
x=2;
textcolor(YELLOW);
gotoxy(x-1,y);
cprintf("%c",204);
for(i=0;i<77;i++)
{
gotoxy(x,y);
textcolor(YELLOW);
cprintf("%c",205);
x++;
}
textcolor(YELLOW);
gotoxy(x,y);
cprintf("%c",185);
}
x=8;
for(j=0;j<7;j++)
{
y=2;
textcolor(YELLOW);
gotoxy(x,y-1);
cprintf("%c",203);
for(i=0;i<23;i++)
{
gotoxy(x,y);
textcolor(YELLOW);
cprintf("%c",186);
y++;
}
textcolor(YELLOW);
gotoxy(x,y);
cprintf("%c",202);
x=x+10;
}
y=4;
for(j=0;j<7;j++)
{
x=8;
for(i=0;i<7;i++)
{
gotoxy(x,y);
cprintf("%c",206);
x+=10;
}
y+=3;
}
gotoxy(1,1);
cprintf("%c",201);
gotoxy(1,49);
cprintf("%c",200);
gotoxy(79,1);
cprintf("%c",187);
gotoxy(79,49);
cprintf("%c",188);
}
/*****************************THE MAIN DISPLAY*****************************/
/*************************OUTPUT OF THE TIME TABLE*************************/
void timetable(char sem,char br)
{
int i,j,x,y;
struct time
{
char teach[25],sub[15],room[5];
}t;
FILE *fp;
if(br=='1')
switch(sem)
{
case '1':
fp=fopen("sem1cse.txt","r");
break;
case '2':
fp=fopen("sem2cse.txt","r");
break;
case '3':
fp=fopen("sem3cse.txt","r");
break;
case '4':
fp=fopen("sem4cse.txt","r");
break;
case '5':
fp=fopen("sem5cse.txt","r");
break;
case '6':
fp=fopen("sem6cse.txt","r");
break;
case '7':
fp=fopen("sem7cse.txt","r");
break;
case '8':
fp=fopen("sem8cse.txt","r");
break;
default:
getch();
textcolor(RED+BLINK);
gotoxy(30,12);
cprintf("WRONG CHOICE!!");
getch();
}
else
if(br=='2')
switch(sem)
{
case '1':
fp=fopen("sem1ece.txt","r");
break;
case '2':
fp=fopen("sem2ece.txt","r");
break;
case '3':
fp=fopen("sem3ece.txt","r");
break;
case '4':
fp=fopen("sem4ece.txt","r");
break;
case '5':
fp=fopen("sem5ece.txt","r");
break;
case '6':
fp=fopen("sem6ece.txt","r");
break;
case '7':
fp=fopen("sem7ece.txt","r");
break;
case '8':
fp=fopen("sem8ece.txt","r");
break;
default:
getch();
textcolor(RED+BLINK);
gotoxy(30,12);
cprintf("WRONG CHOICE!!");
getch();
break;
}
else
if(br=='3')
switch(sem)
{
case '1':
fp=fopen("sem1civ.txt","r");
break;
case '2':
fp=fopen("sem2civ.txt","r");
break;
case '3':
fp=fopen("sem3civ.txt","r");
break;
case '4':
fp=fopen("sem4civ.txt","r");
break;
case '5':
fp=fopen("sem5civ.txt","r");
break;
case '6':
fp=fopen("sem6civ.txt","r");
break;
case '7':
fp=fopen("sem7civ.txt","r");
break;
case '8':
fp=fopen("sem8civ.txt","r");
break;
default:
clrscr();
textcolor(RED+BLINK);
gotoxy(30,12);
cprintf("WRONG CHOICE!!");
getch();
break;
}
else
if(br=='4')
switch(sem)
{
case '1':
fp=fopen("sem1che.txt","r");
break;
case '2':
fp=fopen("sem2che.txt","r");
break;
case '3':
fp=fopen("sem3che.txt","r");
break;
case '4':
fp=fopen("sem4che.txt","r");
break;
case '5':
fp=fopen("sem5che.txt","r");
break;
case '6':
fp=fopen("sem6che.txt","r");
break;
case '7':
fp=fopen("sem7che.txt","r");
break;
case '8':
fp=fopen("sem8che.txt","r");
break;
default:
clrscr();
textcolor(RED+BLINK);
gotoxy(30,12);
cprintf("WRONG CHOICE!!");
getch();
break;
}
else
{
clrscr();
textcolor(RED+BLINK);
gotoxy(30,12);
cprintf("WRONG CHOICE!!");
getch();
}
if(fp==NULL)
{
clrscr();
gotoxy(30,12);
textcolor(RED+BLINK);
cprintf("Cannot Open File!!");
getch();
exit();
}
frame1();
textcolor(RED);
gotoxy(3,5);
cprintf("MON");
textcolor(RED);
gotoxy(3,8);
cprintf("TUE");
textcolor(RED);
gotoxy(3,11);
cprintf("WED");
textcolor(RED);
gotoxy(3,14);
cprintf("THU");
textcolor(RED);
gotoxy(3,17);
cprintf("FRI");
textcolor(RED);
gotoxy(3,20);
cprintf("SAT");
gotoxy(3,23);
cprintf("SUN");
gotoxy(11,2);
cprintf("9:00");
gotoxy(21,2);
cprintf("10:00");
gotoxy(31,2);
cprintf("11:00");
gotoxy(41,2);
cprintf("12:00");
gotoxy(51,2);
cprintf("1:00");
gotoxy(61,2);
cprintf("2:00");
gotoxy(71,2);
cprintf("3:00");
x=11;
y=5;
while(fscanf(fp,"%s %s %s",t.teach,t.sub,t.room)!=EOF)
{
gotoxy(x,y);
textcolor(GREEN);
cprintf("%s",t.sub);
gotoxy(x,y+1);
cprintf("%s",t.room);
x+=10;
if(x>79)
{
x=11;
y+=3;
}
}
fclose(fp);
getch();
}
/*****************************ANOTHER FRAME********************************/
/****************************THE INPUT FRAME*******************************/
void framei()
{
int i,x,y;
x=23;
y=5;
clrscr();
for(i=0;i<35;i++)
{
gotoxy(x,y);
textcolor(YELLOW);
cprintf("%c",205);
x++;
}
x=23;
y=20;
for(i=0;i<35;i++)
{
gotoxy(x,y);
textcolor(YELLOW);
cprintf("%c",205);
x++;
}
x=23;
y=5;
for(i=0;i<15;i++)
{
gotoxy(x,y);
textcolor(YELLOW);
cprintf("%c",186);
y++;
}
x=57;
y=20;
for(i=15;i>0;i--)
{
gotoxy(x,y);
textcolor(YELLOW);
cprintf("%c",186);
y--;
}
gotoxy(23,5);
cprintf("%c",201);
gotoxy(23,20);
cprintf("%c",200);
gotoxy(57,20);
cprintf("%c",188);
gotoxy(57,5);
cprintf("%c", 187);
}
/************ *****************TEACHER COMES*******************************/
/**********************INPUT FOR TEACHER'S DATAS**************************/
void teacheri()
{
int i;
char nam[25],sub[10],room[20],ch;
FILE *fp;
fp=fopen("teacher.txt","a");
if(fp==NULL)
{
gotoxy(30,12);
textcolor(RED+BLINK);
cprintf("Cannot Open File!!");
exit();
}
framei();
gotoxy(32,4);
textcolor(RED+BLINK);
cprintf("CHECK TEACHER");
gotoxy(25,6);
textcolor(GREEN);
cprintf("1.ENTER NAME OF TEACHER ");
gotoxy(27,7);
gets(nam);
for(i=0;nam[i]!='\0';i++)
if(nam[i]==' ')
nam[i]='_';
gotoxy(25,8);
cprintf("2.ENTER SUBJECT ");
gotoxy(27,9);
gets(sub);
for(i=0;sub[i]!='\0';i++)
if(sub[i]==' ')
sub[i]='_';
gotoxy(25,10);
cprintf("3.ENTER ROOM REQUIRED");
gotoxy(27,11);
gets(room);
for(i=0;room[i]!='\0';i++)
if(room[i]==' ')
room[i]=',';
gotoxy(29,19);
textcolor(MAGENTA + BLINK);
cprintf("SAVE CHANGES (y/n)?");
ch=getch();
if(ch=='y'||ch=='Y')
{
fprintf(fp,"%s %s %s ",nam,sub,room);
fflush(stdin);
}
fclose(fp);
}
/********************************NEW ROOM**********************************/
/************************INPUT FOR ROOM'S DATAS****************************/
void roomi()
{
int cap,i;
char rt[15],rn[5],ch;
FILE *fp;
fp=fopen("room.txt","a");
if(fp==NULL)
{
gotoxy(30,12);
textcolor(RED+BLINK);
cprintf("Cannot Open File!!");
exit();
}
clrscr();
framei();
gotoxy(32,4);
textcolor(RED+BLINK);
cprintf("CHECKROOM");
gotoxy(25,7);
textcolor(GREEN);
cprintf(" 1. ENTER ROOM TYPE ");
gotoxy(27,8);
gets(rt);
for(i=0;rt[i]!='\0';i++)
if(rt[i]==' ')
rt[i]='_';
gotoxy(25,9);
cprintf(" 2. ENTER ROOM NUMBER ");
gotoxy(27,10);
gets(rn);
gotoxy(25,11);
cprintf(" 3. ENTER CAPACITY");
gotoxy(27,12);
scanf("%d",&cap);
gotoxy(28,19);
textcolor(MAGENTA + BLINK);
cprintf("SAVE CHANGES (y/n)?");
ch=getch();
if(ch=='y'||ch=='Y')
{
fprintf(fp,"%s %s %d",rt,rn,cap);
fflush(stdin);
}
fclose(fp);
}
/*****************************TIME TABLE ENTRY*******************************/
/***************************INPUT FOR TIME TABLE*****************************/
void timetablei(char sem,char br)
{
int i,j,k,p=0;
char teach[25],sub[15],room[5];
FILE *fp;
if(br=='1')
switch(sem)
{
case '1':
fp=fopen("sem1cse.txt","w");
break;
case '2':
fp=fopen("sem2cse.txt","w");
break;
case '3':
fp=fopen("sem3cse.txt","w");
break;
case '4':
fp=fopen("sem4cse.txt","w");
break;
case '5':
fp=fopen("sem5cse.txt","w");
break;
case '6':
fp=fopen("sem6cse.txt","w");
break;
case '7':
fp=fopen("sem7cse.txt","w");
break;
case '8':
fp=fopen("sem8cse.txt","w");
break;
default:
clrscr();
textcolor(RED+BLINK);
gotoxy(30,12);
cprintf("WRONG CHOICE!!");
getch();
break;
}
else
if(br=='2')
switch(sem)
{
case '1':
fp=fopen("sem1ece.txt","w");
break;
case '2':
fp=fopen("sem2ece.txt","w");
break;
case '3':
fp=fopen("sem3ece.txt","w");
break;
case '4':
fp=fopen("sem4ece.txt","w");
break;
case '5':
fp=fopen("sem5ece.txt","w");
break;
case '6':
fp=fopen("sem6ece.txt","w");
break;
case '7':
fp=fopen("sem7ece.txt","w");
break;
case '8':
fp=fopen("sem8ece.txt","w");
break;
default:
clrscr();
textcolor(RED+BLINK);
gotoxy(30,12);
cprintf("WRONG CHOICE!!");
getch();
break;
}
else
if(br=='3')
switch(sem)
{
case '1':
fp=fopen("sem1civ.txt","w");
break;
case '2':
fp=fopen("sem2civ.txt","w");
break;
case '3':
fp=fopen("sem3civ.txt","w");
break;
case '4':
fp=fopen("sem4civ.txt","w");
break;
case '5':
fp=fopen("sem5civ.txt","w");
break;
case '6':
fp=fopen("sem6civ.txt","w");
break;
case '7':
fp=fopen("sem7civ.txt","w");
break;
case '8':
fp=fopen("sem8civ.txt","w");
break;
default:
clrscr();
textcolor(RED+BLINK);
gotoxy(30,12);
cprintf("WRONG CHOICE!!");
getch();
break;
}
else
if(br=='4')
switch(sem)
{
case '1':
fp=fopen("sem1che.txt","w");
break;
case '2':
fp=fopen("sem2che.txt","w");
break;
case '3':
fp=fopen("sem3che.txt","w");
break;
case '4':
fp=fopen("sem4che.txt","w");
break;
case '5':
fp=fopen("sem5che.txt","w");
break;
case '6':
fp=fopen("sem6che.txt","w");
break;
case '7':
fp=fopen("sem7che.txt","w");
break;
case '8':
fp=fopen("sem8che.txt","w");
break;
default:
clrscr();
textcolor(RED+BLINK);
gotoxy(30,12);
cprintf("WRONG CHOICE!!");
getch();
break;
}
else
{
textcolor(RED+BLINK);
gotoxy(30,12);
cprintf("WRONG CHOICE!!");
getch();
}
if(fp==NULL)
{
gotoxy(30,12);
textcolor(RED+BLINK);
cprintf("Cannot Open File!!");
getch();
exit();
}
for(j=1;j<=6;j++)
{
clrscr();
gotoxy(30,13);
textcolor(RED);
cprintf("ENTER DETAILS FOR DAY %d",j);
getch();
for(i=1;i<8;i++)
{
framei();
textcolor(WHITE);
gotoxy(29,4);
textcolor(RED+BLINK);
cprintf(" TIME TABLE DETAILS");
gotoxy(25,7);
textcolor(GREEN);
cprintf(" 1. ENTER NAME OF TEACHER ");
gotoxy(27,8);
gets(teach);
for(k=0;teach[k]!='\0';k++)
if(teach[k]==' ')
teach[k]='_';
gotoxy(25,9);
cprintf(" 2. ENTER SUBJECT ");
gotoxy(27,10);
gets(sub);
gotoxy(25,11);
cprintf("3. ENTER ROOM");
gotoxy(27,12);
gets(room);
p=rep(sem,br,teach,room,i,j);
if(p==1)
{
clrscr();
textcolor(RED+BLINK);
gotoxy(30,12);
cprintf("TEACHER IS REPEATED!!");
getch();
i--;
}
else if(p==2)
{
clrscr();
textcolor(RED+BLINK);
gotoxy(30,12);
cprintf("ROOM IS REPEATED!!");
getch();
i--;
}
else
{
fprintf(fp,"%s %s %s ",teach,sub,room);
fflush(stdin);
}
}
fprintf(fp,"\n");
}
fclose(fp);
}
/******************************TEACHER GOES********************************/
/**********************REMOVING TEACHER FROM LIST**************************/
void teacherr()
{
int i;
struct teacher
{
char nam[25],sub[10],room[20];
}t;
char name[25],ch;
FILE *fp,*ft;
if(fp==NULL)
{
gotoxy(30,12);
textcolor(RED+BLINK);
cprintf("Cannot Open File!!");
exit();
}
clrscr();
fp=fopen("teacher.txt","rb+");
framei();
gotoxy(30,4);
textcolor(RED+BLINK);
cprintf("REMOVE TEACHER");
gotoxy(25,6);
textcolor(GREEN);
cprintf("1.ENTER NAME OF TEACHER ");
gotoxy(27,8);
gets(name);
for(i=0;name[i]!='\0';i++)
if(name[i]==' ')
name[i]='_';
gotoxy(27,19);
textcolor(MAGENTA + BLINK);
cprintf("SURE TO REMOVE (y/n)?");
ch=getch();
if(ch=='y'||'Y')
{
ft=fopen("temp.txt","wb");
rewind(fp);
while(fscanf(fp,"%s %s %s",t.nam,t.sub,t.room)!=EOF)
{
if(strcmp(t.nam,name)!=0)
fprintf(ft,"%s %s %s ",t.nam,t.sub,t.room);
}
fclose(ft);
fclose(fp);
remove("teacher.txt");
rename("temp.txt","teacher.txt");
}
}
/******************************ROOM BLOCKS********************************/
/***********************REMOVING ROOM FROM LIST***************************/
void roomr()
{
int i;
struct room
{
char rt[20],rn[15];
int cap;
}r;
char rno[15],ch;
FILE *fp,*ft;
clrscr();
fp=fopen("room.txt","rb+");
if(fp==NULL)
{
gotoxy(30,12);
textcolor(RED+BLINK);
cprintf("Cannot Open File!!");
exit();
}
framei();
gotoxy(30,4);
textcolor(RED+BLINK);
cprintf("REMOVE ROOM");
gotoxy(25,6);
textcolor(GREEN);
cprintf("1.ENTER ROOM NUMBER ");
gotoxy(27,8);
gets(rno);
gotoxy(27,19);
textcolor(MAGENTA + BLINK);
cprintf("SURE TO REMOVE (y/n)?");
ch=getche();
if(ch=='y'||ch=='Y')
{
ft=fopen("temp.txt","wb");
rewind(fp);
while(fscanf(fp,"%s %s %d",r.rt,r.rn,&r.cap)!=EOF)
{
if(strcmp(r.rn,rno)!=0)
fprintf(ft,"%s %s %d ",r.rt,r.rn,r.cap);
fflush(stdin);
}
fclose(ft);
fclose(fp);
remove("room.txt");
rename("temp.txt","room.txt");
}
}
/****************************OOPS! A REPETITION*****************************/
/*****************FUNCTION TO CHECK REPETITION OF INPUT DATA****************/
int rep(char sem,char br,char teach[25],char room[5],int i,int j)
{
FILE *fp;
int m;
struct cmp
{
char teach[25],room[5],sub[10];
}c;
if(br=='1' && sem=='1')
goto next11;
fp=fopen("sem1cse.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next11:
if(br=='1' && sem=='2')
goto next12;
fp=fopen("sem2cse.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next12:
if(br=='1' && sem=='3')
goto next13;
fp=fopen("sem3cse.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next13:
if(br=='1' && sem=='4')
goto next14;
fp=fopen("sem4cse.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next14:
if(br=='1' && sem=='5')
goto next15;
fp=fopen("sem5cse.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next15:
if(br=='1' && sem=='6')
goto next16;
fp=fopen("sem6cse.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next16:
if(br=='1' && sem=='7')
goto next17;
fp=fopen("sem7cse.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next17:
if(br=='1' && sem=='8')
goto next18;
fp=fopen("sem8cse.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next18:
if(br=='2' && sem=='1')
goto next21;
fp=fopen("sem1ece.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next21:
if(br=='2' && sem=='2')
goto next22;
fp=fopen("sem2ece.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next22:
if(br=='2' && sem=='3')
goto next23;
fp=fopen("sem3ece.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next23:
if(br=='2' && sem=='4')
goto next24;
fp=fopen("sem4ece.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next24:
if(br=='2' && sem=='5')
goto next25;
fp=fopen("sem5ece.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next25:
if(br=='2' && sem=='6')
goto next26;
fp=fopen("sem6ece.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next26:
if(br=='2' && sem=='7')
goto next27;
fp=fopen("sem7ece.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next27:
if(br=='2' && sem=='8')
goto next28;
fp=fopen("sem8ece.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next28:
if(br=='3' && sem=='1')
goto next31;
fp=fopen("sem1civ.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next31:
if(br=='3' && sem=='2')
goto next32;
fp=fopen("sem2civ.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next32:
if(br=='3' && sem=='3')
goto next13;
fp=fopen("sem3civ.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next33:
if(br=='3' && sem=='4')
goto next34;
fp=fopen("sem4civ.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (1);
}
fclose(fp);
next34:
if(br=='3' && sem=='5')
goto next35;
fp=fopen("sem5civ.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next35:
if(br=='3' && sem=='6')
goto next36;
fp=fopen("sem6civ.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next36:
if(br=='3' && sem=='7')
goto next37;
fp=fopen("sem7civ.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next37:
if(br=='3' && sem=='8')
goto next38;
fp=fopen("sem8civ.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next38:
if(br=='4' && sem=='1')
goto next41;
fp=fopen("sem1che.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next41:
if(br=='4' && sem=='2')
goto next42;
fp=fopen("sem2che.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next42:
if(br=='4' && sem=='3')
goto next43;
fp=fopen("sem3che.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next43:
if(br=='4' && sem=='4')
goto next44;
fp=fopen("sem4che.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next44:
if(br=='4' && sem=='5')
goto next45;
fp=fopen("sem5che.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next45:
if(br=='4' && sem=='6')
goto next46;
fp=fopen("sem6che.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next46:
if(br=='4' && sem=='7')
goto next47;
fp=fopen("sem7che.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next47:
if(br=='4' && sem=='8')
goto next48;
fp=fopen("sem8che.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next48:
return (0);
}
/******************************WHICH SEMESTER?******************************/
/***************************FUNCTION FOR SEMESTER***************************/
char semester()
{
char ch;
framei();
gotoxy(29,4);
textcolor(RED+BLINK);
cprintf("SEMESTER");
gotoxy(25,7);
textcolor(GREEN);
cprintf("1.SEMESTER");
gotoxy(25,8);
cprintf("2.SEMESTER");
gotoxy(25,9);
cprintf("3.SEMESTER");
gotoxy(25,10);
cprintf("4.SEMESTER");
gotoxy(25,11);
cprintf("5.SEMESTER");
gotoxy(25,12);
cprintf("6.SEMESTER");
gotoxy(25,13);
cprintf("7.SEMESTER");
gotoxy(25,14);
cprintf("8.SEMESTER");
textcolor(MAGENTA);
gotoxy(27,19);
cprintf("ENTER CHOICE:");
ch=getche();
return(ch);
}
/***************************WHICH BRANCH?*********************************/
/************************SELECTION OF BRANCH******************************/
char branch()
{
char ch;
framei();
gotoxy(31,4);
textcolor(RED+BLINK);
cprintf("BRANCH");
gotoxy(25,7);
textcolor(GREEN);
cprintf("1.COMPUTER SCIENCE");
gotoxy(25,9);
cprintf("2.ELECTRONICS");
gotoxy(25,11);
cprintf("3.CIVIL");
gotoxy(25,13);
cprintf("4.CHEMICAL");
textcolor(MAGENTA);
gotoxy(27,19);
cprintf("ENTER CHOICE:");
ch=getche();
return(ch);
}
/***************************THE COLLECTION**********************************/
/**************************THE MAIN FUNCTION********************************/
void main()
{
char ch='a',sem,br;
clrscr();
first();
while(ch!='0')
{
ch=file();
textcolor(WHITE);
switch (ch)
{
case '0':
break;
case '1':
teacheri();
break;
case '2':
roomi();
break;
case '3':
teacherr ();
break;
case '4':
roomr();
break;
case '5':
frame();
teacher();
getch();
break;
case '6':
frame();
room();
getch();
break;
case '7':
sem=semester();
br=branch();
timetablei(sem,br);
break;
case '8':
sem=semester();
br=branch();
timetable(sem,br);
break;
default:
textcolor(RED+BLINK);
gotoxy(30,10);
cprintf("WRONG CHOICE!!!");
getch();
break;
}
}
}
/**************************************************************************/
/********************************THE END***********************************/
/**************************************************************************/
only run it & doooom u get best o/p...
*************************************************************************************
/* GAME OF NUMBERS IMPLEMENTATION */
# include
# include
# include
# include
# define UP_ARROW 72 /* Scan code of up arrow */
# define DOWN_ARROW 80 /* Scan code of down arrow */
# define LEFT_ARROW 75 /* Scan code of left arrow */
# define RIGHT_ARROW 77 /* Scan code of right arrow */
# define ESC 1 /* Scan code of escape key */
int a[4][4]={ /* Array to store the numbers */
{4,6,12,1},
{2,8,10,14},
{3,7,13,9},
{5,11,15,0}
};
int r=3; /* Row of the array */
int c=3; /* Coloumn of the array */
int moves=0; /* To count no. of moves */
/* Prototype Declaration */
void Display(void); /* Prototype of display function */
void Boxes(void); /* Prototype of boxes function */
void Game(void); /* Prototype of game function */
void Esc(void); /* Prototype of escape function */
int Getkey(void); /* Prototype of getkey function */
void Install(void); /* Prototype of install function */
void Rules(void); /* Prototype of rules function */
void Win(void); /* Prototype of win function */
/* Main Game Function */
void Game(void)
{
int ch;
int temp;
Boxes();
Display();
while(1)
{
ch=Getkey();
switch(ch)
{
case DOWN_ARROW :
if(r==0)
{
printf("a");
break;
}
temp=a[r][c];
a[r][c]=a[r-1][c];
a[r-1][c]=temp;
r--;
moves++;
Display();
break;
case UP_ARROW :
if(r==3)
{
printf("a");
break;
}
temp=a[r][c];
a[r][c]=a[r+1][c];
a[r+1][c]=temp;
r++;
moves++;
Display();
break;
case LEFT_ARROW :
if(c==3)
{
printf("a");
break;
}
temp=a[r][c];
a[r][c]=a[r][c+1];
a[r][c+1]=temp;
c++;
moves++;
Display();
break;
case RIGHT_ARROW :
if(c==0)
{
printf("a");
break;
}
temp=a[r][c];
a[r][c]=a[r][c-1];
a[r][c-1]=temp;
c--;
moves++;
Display();
break;
case ESC :
Esc();
break;
default :
break;
}
}
}
/* Escape Function */
void Esc(void)
{
Win();
gotoxy(27,22);
textcolor(LIGHTGREEN);
cprintf("No. of moves = %d",moves);
getch();
exit(0);
}
/* Display Function */
void Display(void)
{
int r1=9,c1=30;
int i,j;
textcolor(MAGENTA);
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
if(a[i][j]==0)
{
gotoxy(c1,r1);
cprintf(" ");
}
else
{
gotoxy(c1,r1);
cprintf("%d",a[i][j]);
}
c1=c1+3;
}
c1=30;
r1=r1+2;
}
}
/* Function To Draw Boxes */
void Boxes(void)
{
int i,j;
gotoxy(26,3);
textcolor(MAGENTA);
cprintf("GAME OF THE CENTURY");
textcolor(YELLOW);
for(i=8;i<=16;i=i+2)
{
for(j=29;j<=41;j++)
{
gotoxy(j,i);
cprintf("%c",196);
}
}
for(i=29;i<=42;i=i+3)
{
for(j=8;j<=16;j++)
{
gotoxy(i,j);
cprintf("%c",179);
}
}
gotoxy(29,8);
cprintf("%c",218);
gotoxy(29,16);
cprintf("%c",192);
gotoxy(41,8);
cprintf("%c",191);
gotoxy(41,16);
cprintf("%c",217);
for(i=32;i<=38;i=i+3)
{
gotoxy(i,8);
cprintf("%c",194);
}
for(i=32;i<=38;i=i+3)
{
gotoxy(i,16);
cprintf("%c",193);
}
for(i=10;i<=14;i=i+2)
{
for(j=32;j<=38;j=j+3)
{
gotoxy(j,i);
cprintf("%c",197);
}
}
for(i=10;i<=14;i=i+2)
{
gotoxy(29,i);
cprintf("%c",195);
}
for(i=10;i<=14;i=i+2)
{
gotoxy(41,i);
cprintf("%c",180);
}
}
/* Function To Get The Scan Code of Key */
int Getkey(void)
{
union REGS i,o;
while(!kbhit());
i.h.ah=0;
int86(22,&i,&o);
return(o.h.ah);
}
/* Install Menu Function */
void Install(void)
{
int i,j;
int c=11,r=19;
int time=0;
gotoxy(32,13);
textcolor(BROWN);
cprintf("INSTALLING MENU");
textcolor(YELLOW);
gotoxy(1,19);
cprintf("Installing");
for(i=20;i<=22;i=i+2)
{
for(j=1;j<=80;j++)
{
gotoxy(j,i);
cprintf("%c",196);
}
}
for(i=20;i<=22;i++)
{
gotoxy(1,i);
cprintf("%c",179);
}
for(i=20;i<=22;i++)
{
gotoxy(80,i);
cprintf("%c",179);
}
gotoxy(1,20);
cprintf("%c",218);
gotoxy(1,22);
cprintf("%c",192);
gotoxy(80,20);
cprintf("%c",191);
gotoxy(80,22);
cprintf("%c",217);
for(i=2;i<=79;i++)
{
gotoxy(i,21);
printf("%c",176);
}
for(i=2;i<=79;i++)
{
gotoxy(i,21);
delay(500);
textcolor(BLUE);
cprintf("%c",219);
gotoxy(67,19);
printf(" ");
if(c==15)
{
for(j=11;j<=15;j++)
{
gotoxy(j,19);
printf(" ");
}
c=11;
}
gotoxy(c,r);
textcolor(YELLOW);
cprintf(".");
c++;
gotoxy(67,19);
textcolor(YELLOW);
cprintf("%d% Completed",time);
if(time<=60)
{
time++;
}
else if(time<=71)
time=time+2;
else
time=time+3;
if(i==78)
time=time-3;
}
}
/* Rules Menu Function */
void Rules(void)
{
int i;
textcolor(LIGHTCYAN);
gotoxy(39,5);
cprintf("RULES");
textcolor(GREEN);
gotoxy(18,7);
cprintf("1. Your aim is to arrange numbers in ascending order");
gotoxy(18,9);
cprintf("2. The player with minimum no. of moves wins the game");
textcolor(LIGHTGRAY);
for(i=17;i<=71;i++)
{
gotoxy(i,6);
cprintf("%c",196);
}
for(i=17;i<=71;i++)
{
gotoxy(i,10);
cprintf("%c",196);
}
for(i=6;i<=10;i++)
{
gotoxy(17,i);
cprintf("%c",179);
}
for(i=6;i<=10;i++)
{
gotoxy(71,i);
cprintf("%c",179);
}
gotoxy(17,6);
cprintf("%c",218);
gotoxy(17,10);
cprintf("%c",192);
gotoxy(71,6);
cprintf("%c",191);
gotoxy(71,10);
cprintf("%c",217);
}
/* Function To Check For Win */
void Win(void)
{
int i,j,pos;
int flag=1;
int arr[20];
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
pos=i*4+j;
arr[pos]=a[i][j];
}
}
for(i=0;i
if(arr[i]>arr[i+1])
{
flag=0;
break;
}
}
if(flag==1)
{
gotoxy(30,21);
printf("YOU WIN");
}
}
/* The Main Function */
void main(void)
{
clrscr();
Install();
sleep(1);
clrscr();
Rules();
getch();
clrscr();
Game();
getch();
}
*************************************************************************************
=====================================================================================
/****************************************************************************
*****************************************************************************
"THE SCHEDULER"
THE PROJECT IS MADE FOR THE EXECUTION OF TIME TABLES. A COMMON PROBLEM ARISES THAT A COMMON ROOM OR A COMMON TEACHER IS SHARED BY TWO OR MORE CLASSES. THIS PROJECT IS TO SOLVE PROBLEMS LIKE THIS.
*****************************************************************************
****************************************************************************/
/***************************************************************************/
/*******************************HEADER FILES********************************/
/***************************************************************************/
#include
#include
#include
#include
/*******************************LETS START*********************************/
/***************************THE WELCOME SCREEN*****************************/
void first()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
setcolor(GREEN);
settextstyle(4,0,8);
outtextxy(200,50,"TIME");
setcolor(YELLOW);
settextstyle(4,0,8);
outtextxy(100,190,"SCHEDULER");
settextstyle(1,0,1);
setcolor(RED);
outtextxy(480,350,"Made By:");
setcolor(BLUE);
outtextxy(480,370,"Atiq Anwar");
getch();
restorecrtmode();
}
/******************************WORK BEGINS********************************/
/**********************FUNCTION FOR THE 'MAIN MENU'***********************/
char file()
{
int gdriver=DETECT, gmod;
char i;
initgraph(&gdriver,&gmod,"c:\\tc\\bgi");
setcolor(RED);
rectangle(170,85,430,385);
rectangle(175,90, 425,380);
setcolor(GREEN);
settextstyle(7,0,4);
outtextxy(130,45,"TIME TABLE MANAGER");
settextstyle(7,0,3);
setcolor(YELLOW);
outtextxy(260,95,"MENU");
settextstyle(0,0,0);
setcolor(MAGENTA);
outtextxy(200,145,"1>>ENTER TEACHER.");
outtextxy(200,170,"2>>ENTER ROOM.");
outtextxy(200,195,"3>>REMOVE TEACHER.");
outtextxy(200,220,"4>>REMOVE ROOM.");
outtextxy(200,245,"5>>VIEW TEACHER.");
outtextxy(200,270,"6>>VIEW ROOM.");
outtextxy(200,295,"7>>CREATE TIME TABLE.");
outtextxy(200,320,"8>>VIEW TIME TABLE.");
outtextxy(200,343,"0>>EXIT.");
setcolor(GREEN+BLINK);
outtextxy(200,360,"ENTER YOUR CHOICE:");
i=getche();
restorecrtmode();
return (i);
}
/********************************OUTLINES********************************/
/************************THE COMMON DISPLAY FRAME************************/
void frame()
{
int x,y,i,j;
clrscr();
x=0;
y=0;
for(i=0;i<78;i++)
{
gotoxy(x,y);
textcolor(YELLOW);
cprintf("%c",205);
x++;
}
x=0;
y=25;
for(i=0;i<80;i++)
{
gotoxy(x,y);
textcolor(YELLOW);
cprintf("%c",205);
x++;
}
x=1;
y=1;
for(i=0;i<25;i++)
{
gotoxy(x,y);
textcolor(YELLOW);
cprintf("%c",186);
y++;
}
x=79;
y=1;
for(i=0;i<25;i++)
{
gotoxy(x,y);
textcolor(YELLOW);
cprintf("%c",186);
y++;
}
gotoxy(1,1);
cprintf("%c",201);
gotoxy(1,25);
cprintf("%c",200);
gotoxy(79,1);
cprintf("%c",187);
gotoxy(79,25);
cprintf("%c",188);
}
/*****************************TEACHER COMES*******************************/
/**********************OUTPUT FOR TEACHER'S DATAS**************************/
void teacher()
{
int i;
struct teacher
{
char nam[25],sub[15],room[15];
}t;
FILE *fp;
fp=fopen("teacher.txt","r");
if(fp==NULL)
{
gotoxy(30,12);
textcolor(RED+BLINK);
cprintf("Cannot Open File!!");
exit();
}
frame();
textcolor(GREEN);
gotoxy(5,2);
cprintf("Name");
gotoxy(35,2);
cprintf("Subject");
gotoxy(68,2);
cprintf("Choice");
for(i=3;i<=77;i++)
{
textcolor(YELLOW);
gotoxy(i,3);
cprintf("-");
}
i=4;
while(fscanf(fp,"%s %s %s ",t.nam,t.sub,t.room)!=EOF)
{
gotoxy(5,i);
printf("%s",t.nam);
gotoxy(35,i);
printf("%s",t.sub);
gotoxy(68,i);
printf("%s",t.room);
i++;
if(i > 20)
{
clrscr();
frame();
textcolor(GREEN);
gotoxy(5,2);
cprintf("Name");
gotoxy(35,2);
cprintf("Subject");
gotoxy(68,2);
cprintf("Choice");
for(i=3;i<=77;i++)
{
textcolor(YELLOW);
gotoxy(i,3);
cprintf("-");
}
i=4;
}
}
fclose(fp);
}
/*******************************ROOM OPENS********************************/
/************************OUTPUT FOR ROOM'S DATAS***************************/
void room()
{
struct room
{
int cap;
char rt[20],rn[15];
}r;
int i;
FILE *fp;
clrscr();
fp=fopen("room.txt","r");
if(fp==NULL)
{
gotoxy(30,12);
textcolor(RED+BLINK);
cprintf("Cannot Open File!!");
exit();
}
frame();
textcolor(GREEN);
gotoxy(5,2);
cprintf("Room");
gotoxy(35,2);
cprintf("Room Code");
gotoxy(68,2);
cprintf("Capacity");
for(i=3;i<=77;i++)
{
textcolor(YELLOW);
gotoxy(i,3);
cprintf("-");
}
i=4;
while(fscanf(fp,"%s %s %d",r.rt,r.rn,&r.cap)!=EOF)
{
gotoxy(5,i);
printf("%s",r.rt);
gotoxy(35,i);
printf("%s",r.rn);
gotoxy(68,i);
printf("%d",r.cap);
i++;
if(i > 20)
{
getch();
clrscr();
frame();
textcolor(GREEN);
gotoxy(5,2);
cprintf("Room");
gotoxy(35,2);
cprintf("Room Code");
gotoxy(68,2);
cprintf("Capacity");
for(i=3;i<=77;i++)
{
textcolor(YELLOW);
gotoxy(i,3);
cprintf("-");
}
i=4;
}
}
fclose(fp);
}
/******************************MAIN FRAME*********************************/
/*************************THE TIME TABLE GRID*****************************/
void frame1()
{
int x,y,i,j,h;
clrscr();
frame();
for(y=4;y<23;y+=3)
{
x=2;
textcolor(YELLOW);
gotoxy(x-1,y);
cprintf("%c",204);
for(i=0;i<77;i++)
{
gotoxy(x,y);
textcolor(YELLOW);
cprintf("%c",205);
x++;
}
textcolor(YELLOW);
gotoxy(x,y);
cprintf("%c",185);
}
x=8;
for(j=0;j<7;j++)
{
y=2;
textcolor(YELLOW);
gotoxy(x,y-1);
cprintf("%c",203);
for(i=0;i<23;i++)
{
gotoxy(x,y);
textcolor(YELLOW);
cprintf("%c",186);
y++;
}
textcolor(YELLOW);
gotoxy(x,y);
cprintf("%c",202);
x=x+10;
}
y=4;
for(j=0;j<7;j++)
{
x=8;
for(i=0;i<7;i++)
{
gotoxy(x,y);
cprintf("%c",206);
x+=10;
}
y+=3;
}
gotoxy(1,1);
cprintf("%c",201);
gotoxy(1,49);
cprintf("%c",200);
gotoxy(79,1);
cprintf("%c",187);
gotoxy(79,49);
cprintf("%c",188);
}
/*****************************THE MAIN DISPLAY*****************************/
/*************************OUTPUT OF THE TIME TABLE*************************/
void timetable(char sem,char br)
{
int i,j,x,y;
struct time
{
char teach[25],sub[15],room[5];
}t;
FILE *fp;
if(br=='1')
switch(sem)
{
case '1':
fp=fopen("sem1cse.txt","r");
break;
case '2':
fp=fopen("sem2cse.txt","r");
break;
case '3':
fp=fopen("sem3cse.txt","r");
break;
case '4':
fp=fopen("sem4cse.txt","r");
break;
case '5':
fp=fopen("sem5cse.txt","r");
break;
case '6':
fp=fopen("sem6cse.txt","r");
break;
case '7':
fp=fopen("sem7cse.txt","r");
break;
case '8':
fp=fopen("sem8cse.txt","r");
break;
default:
getch();
textcolor(RED+BLINK);
gotoxy(30,12);
cprintf("WRONG CHOICE!!");
getch();
}
else
if(br=='2')
switch(sem)
{
case '1':
fp=fopen("sem1ece.txt","r");
break;
case '2':
fp=fopen("sem2ece.txt","r");
break;
case '3':
fp=fopen("sem3ece.txt","r");
break;
case '4':
fp=fopen("sem4ece.txt","r");
break;
case '5':
fp=fopen("sem5ece.txt","r");
break;
case '6':
fp=fopen("sem6ece.txt","r");
break;
case '7':
fp=fopen("sem7ece.txt","r");
break;
case '8':
fp=fopen("sem8ece.txt","r");
break;
default:
getch();
textcolor(RED+BLINK);
gotoxy(30,12);
cprintf("WRONG CHOICE!!");
getch();
break;
}
else
if(br=='3')
switch(sem)
{
case '1':
fp=fopen("sem1civ.txt","r");
break;
case '2':
fp=fopen("sem2civ.txt","r");
break;
case '3':
fp=fopen("sem3civ.txt","r");
break;
case '4':
fp=fopen("sem4civ.txt","r");
break;
case '5':
fp=fopen("sem5civ.txt","r");
break;
case '6':
fp=fopen("sem6civ.txt","r");
break;
case '7':
fp=fopen("sem7civ.txt","r");
break;
case '8':
fp=fopen("sem8civ.txt","r");
break;
default:
clrscr();
textcolor(RED+BLINK);
gotoxy(30,12);
cprintf("WRONG CHOICE!!");
getch();
break;
}
else
if(br=='4')
switch(sem)
{
case '1':
fp=fopen("sem1che.txt","r");
break;
case '2':
fp=fopen("sem2che.txt","r");
break;
case '3':
fp=fopen("sem3che.txt","r");
break;
case '4':
fp=fopen("sem4che.txt","r");
break;
case '5':
fp=fopen("sem5che.txt","r");
break;
case '6':
fp=fopen("sem6che.txt","r");
break;
case '7':
fp=fopen("sem7che.txt","r");
break;
case '8':
fp=fopen("sem8che.txt","r");
break;
default:
clrscr();
textcolor(RED+BLINK);
gotoxy(30,12);
cprintf("WRONG CHOICE!!");
getch();
break;
}
else
{
clrscr();
textcolor(RED+BLINK);
gotoxy(30,12);
cprintf("WRONG CHOICE!!");
getch();
}
if(fp==NULL)
{
clrscr();
gotoxy(30,12);
textcolor(RED+BLINK);
cprintf("Cannot Open File!!");
getch();
exit();
}
frame1();
textcolor(RED);
gotoxy(3,5);
cprintf("MON");
textcolor(RED);
gotoxy(3,8);
cprintf("TUE");
textcolor(RED);
gotoxy(3,11);
cprintf("WED");
textcolor(RED);
gotoxy(3,14);
cprintf("THU");
textcolor(RED);
gotoxy(3,17);
cprintf("FRI");
textcolor(RED);
gotoxy(3,20);
cprintf("SAT");
gotoxy(3,23);
cprintf("SUN");
gotoxy(11,2);
cprintf("9:00");
gotoxy(21,2);
cprintf("10:00");
gotoxy(31,2);
cprintf("11:00");
gotoxy(41,2);
cprintf("12:00");
gotoxy(51,2);
cprintf("1:00");
gotoxy(61,2);
cprintf("2:00");
gotoxy(71,2);
cprintf("3:00");
x=11;
y=5;
while(fscanf(fp,"%s %s %s",t.teach,t.sub,t.room)!=EOF)
{
gotoxy(x,y);
textcolor(GREEN);
cprintf("%s",t.sub);
gotoxy(x,y+1);
cprintf("%s",t.room);
x+=10;
if(x>79)
{
x=11;
y+=3;
}
}
fclose(fp);
getch();
}
/*****************************ANOTHER FRAME********************************/
/****************************THE INPUT FRAME*******************************/
void framei()
{
int i,x,y;
x=23;
y=5;
clrscr();
for(i=0;i<35;i++)
{
gotoxy(x,y);
textcolor(YELLOW);
cprintf("%c",205);
x++;
}
x=23;
y=20;
for(i=0;i<35;i++)
{
gotoxy(x,y);
textcolor(YELLOW);
cprintf("%c",205);
x++;
}
x=23;
y=5;
for(i=0;i<15;i++)
{
gotoxy(x,y);
textcolor(YELLOW);
cprintf("%c",186);
y++;
}
x=57;
y=20;
for(i=15;i>0;i--)
{
gotoxy(x,y);
textcolor(YELLOW);
cprintf("%c",186);
y--;
}
gotoxy(23,5);
cprintf("%c",201);
gotoxy(23,20);
cprintf("%c",200);
gotoxy(57,20);
cprintf("%c",188);
gotoxy(57,5);
cprintf("%c", 187);
}
/************ *****************TEACHER COMES*******************************/
/**********************INPUT FOR TEACHER'S DATAS**************************/
void teacheri()
{
int i;
char nam[25],sub[10],room[20],ch;
FILE *fp;
fp=fopen("teacher.txt","a");
if(fp==NULL)
{
gotoxy(30,12);
textcolor(RED+BLINK);
cprintf("Cannot Open File!!");
exit();
}
framei();
gotoxy(32,4);
textcolor(RED+BLINK);
cprintf("CHECK TEACHER");
gotoxy(25,6);
textcolor(GREEN);
cprintf("1.ENTER NAME OF TEACHER ");
gotoxy(27,7);
gets(nam);
for(i=0;nam[i]!='\0';i++)
if(nam[i]==' ')
nam[i]='_';
gotoxy(25,8);
cprintf("2.ENTER SUBJECT ");
gotoxy(27,9);
gets(sub);
for(i=0;sub[i]!='\0';i++)
if(sub[i]==' ')
sub[i]='_';
gotoxy(25,10);
cprintf("3.ENTER ROOM REQUIRED");
gotoxy(27,11);
gets(room);
for(i=0;room[i]!='\0';i++)
if(room[i]==' ')
room[i]=',';
gotoxy(29,19);
textcolor(MAGENTA + BLINK);
cprintf("SAVE CHANGES (y/n)?");
ch=getch();
if(ch=='y'||ch=='Y')
{
fprintf(fp,"%s %s %s ",nam,sub,room);
fflush(stdin);
}
fclose(fp);
}
/********************************NEW ROOM**********************************/
/************************INPUT FOR ROOM'S DATAS****************************/
void roomi()
{
int cap,i;
char rt[15],rn[5],ch;
FILE *fp;
fp=fopen("room.txt","a");
if(fp==NULL)
{
gotoxy(30,12);
textcolor(RED+BLINK);
cprintf("Cannot Open File!!");
exit();
}
clrscr();
framei();
gotoxy(32,4);
textcolor(RED+BLINK);
cprintf("CHECKROOM");
gotoxy(25,7);
textcolor(GREEN);
cprintf(" 1. ENTER ROOM TYPE ");
gotoxy(27,8);
gets(rt);
for(i=0;rt[i]!='\0';i++)
if(rt[i]==' ')
rt[i]='_';
gotoxy(25,9);
cprintf(" 2. ENTER ROOM NUMBER ");
gotoxy(27,10);
gets(rn);
gotoxy(25,11);
cprintf(" 3. ENTER CAPACITY");
gotoxy(27,12);
scanf("%d",&cap);
gotoxy(28,19);
textcolor(MAGENTA + BLINK);
cprintf("SAVE CHANGES (y/n)?");
ch=getch();
if(ch=='y'||ch=='Y')
{
fprintf(fp,"%s %s %d",rt,rn,cap);
fflush(stdin);
}
fclose(fp);
}
/*****************************TIME TABLE ENTRY*******************************/
/***************************INPUT FOR TIME TABLE*****************************/
void timetablei(char sem,char br)
{
int i,j,k,p=0;
char teach[25],sub[15],room[5];
FILE *fp;
if(br=='1')
switch(sem)
{
case '1':
fp=fopen("sem1cse.txt","w");
break;
case '2':
fp=fopen("sem2cse.txt","w");
break;
case '3':
fp=fopen("sem3cse.txt","w");
break;
case '4':
fp=fopen("sem4cse.txt","w");
break;
case '5':
fp=fopen("sem5cse.txt","w");
break;
case '6':
fp=fopen("sem6cse.txt","w");
break;
case '7':
fp=fopen("sem7cse.txt","w");
break;
case '8':
fp=fopen("sem8cse.txt","w");
break;
default:
clrscr();
textcolor(RED+BLINK);
gotoxy(30,12);
cprintf("WRONG CHOICE!!");
getch();
break;
}
else
if(br=='2')
switch(sem)
{
case '1':
fp=fopen("sem1ece.txt","w");
break;
case '2':
fp=fopen("sem2ece.txt","w");
break;
case '3':
fp=fopen("sem3ece.txt","w");
break;
case '4':
fp=fopen("sem4ece.txt","w");
break;
case '5':
fp=fopen("sem5ece.txt","w");
break;
case '6':
fp=fopen("sem6ece.txt","w");
break;
case '7':
fp=fopen("sem7ece.txt","w");
break;
case '8':
fp=fopen("sem8ece.txt","w");
break;
default:
clrscr();
textcolor(RED+BLINK);
gotoxy(30,12);
cprintf("WRONG CHOICE!!");
getch();
break;
}
else
if(br=='3')
switch(sem)
{
case '1':
fp=fopen("sem1civ.txt","w");
break;
case '2':
fp=fopen("sem2civ.txt","w");
break;
case '3':
fp=fopen("sem3civ.txt","w");
break;
case '4':
fp=fopen("sem4civ.txt","w");
break;
case '5':
fp=fopen("sem5civ.txt","w");
break;
case '6':
fp=fopen("sem6civ.txt","w");
break;
case '7':
fp=fopen("sem7civ.txt","w");
break;
case '8':
fp=fopen("sem8civ.txt","w");
break;
default:
clrscr();
textcolor(RED+BLINK);
gotoxy(30,12);
cprintf("WRONG CHOICE!!");
getch();
break;
}
else
if(br=='4')
switch(sem)
{
case '1':
fp=fopen("sem1che.txt","w");
break;
case '2':
fp=fopen("sem2che.txt","w");
break;
case '3':
fp=fopen("sem3che.txt","w");
break;
case '4':
fp=fopen("sem4che.txt","w");
break;
case '5':
fp=fopen("sem5che.txt","w");
break;
case '6':
fp=fopen("sem6che.txt","w");
break;
case '7':
fp=fopen("sem7che.txt","w");
break;
case '8':
fp=fopen("sem8che.txt","w");
break;
default:
clrscr();
textcolor(RED+BLINK);
gotoxy(30,12);
cprintf("WRONG CHOICE!!");
getch();
break;
}
else
{
textcolor(RED+BLINK);
gotoxy(30,12);
cprintf("WRONG CHOICE!!");
getch();
}
if(fp==NULL)
{
gotoxy(30,12);
textcolor(RED+BLINK);
cprintf("Cannot Open File!!");
getch();
exit();
}
for(j=1;j<=6;j++)
{
clrscr();
gotoxy(30,13);
textcolor(RED);
cprintf("ENTER DETAILS FOR DAY %d",j);
getch();
for(i=1;i<8;i++)
{
framei();
textcolor(WHITE);
gotoxy(29,4);
textcolor(RED+BLINK);
cprintf(" TIME TABLE DETAILS");
gotoxy(25,7);
textcolor(GREEN);
cprintf(" 1. ENTER NAME OF TEACHER ");
gotoxy(27,8);
gets(teach);
for(k=0;teach[k]!='\0';k++)
if(teach[k]==' ')
teach[k]='_';
gotoxy(25,9);
cprintf(" 2. ENTER SUBJECT ");
gotoxy(27,10);
gets(sub);
gotoxy(25,11);
cprintf("3. ENTER ROOM");
gotoxy(27,12);
gets(room);
p=rep(sem,br,teach,room,i,j);
if(p==1)
{
clrscr();
textcolor(RED+BLINK);
gotoxy(30,12);
cprintf("TEACHER IS REPEATED!!");
getch();
i--;
}
else if(p==2)
{
clrscr();
textcolor(RED+BLINK);
gotoxy(30,12);
cprintf("ROOM IS REPEATED!!");
getch();
i--;
}
else
{
fprintf(fp,"%s %s %s ",teach,sub,room);
fflush(stdin);
}
}
fprintf(fp,"\n");
}
fclose(fp);
}
/******************************TEACHER GOES********************************/
/**********************REMOVING TEACHER FROM LIST**************************/
void teacherr()
{
int i;
struct teacher
{
char nam[25],sub[10],room[20];
}t;
char name[25],ch;
FILE *fp,*ft;
if(fp==NULL)
{
gotoxy(30,12);
textcolor(RED+BLINK);
cprintf("Cannot Open File!!");
exit();
}
clrscr();
fp=fopen("teacher.txt","rb+");
framei();
gotoxy(30,4);
textcolor(RED+BLINK);
cprintf("REMOVE TEACHER");
gotoxy(25,6);
textcolor(GREEN);
cprintf("1.ENTER NAME OF TEACHER ");
gotoxy(27,8);
gets(name);
for(i=0;name[i]!='\0';i++)
if(name[i]==' ')
name[i]='_';
gotoxy(27,19);
textcolor(MAGENTA + BLINK);
cprintf("SURE TO REMOVE (y/n)?");
ch=getch();
if(ch=='y'||'Y')
{
ft=fopen("temp.txt","wb");
rewind(fp);
while(fscanf(fp,"%s %s %s",t.nam,t.sub,t.room)!=EOF)
{
if(strcmp(t.nam,name)!=0)
fprintf(ft,"%s %s %s ",t.nam,t.sub,t.room);
}
fclose(ft);
fclose(fp);
remove("teacher.txt");
rename("temp.txt","teacher.txt");
}
}
/******************************ROOM BLOCKS********************************/
/***********************REMOVING ROOM FROM LIST***************************/
void roomr()
{
int i;
struct room
{
char rt[20],rn[15];
int cap;
}r;
char rno[15],ch;
FILE *fp,*ft;
clrscr();
fp=fopen("room.txt","rb+");
if(fp==NULL)
{
gotoxy(30,12);
textcolor(RED+BLINK);
cprintf("Cannot Open File!!");
exit();
}
framei();
gotoxy(30,4);
textcolor(RED+BLINK);
cprintf("REMOVE ROOM");
gotoxy(25,6);
textcolor(GREEN);
cprintf("1.ENTER ROOM NUMBER ");
gotoxy(27,8);
gets(rno);
gotoxy(27,19);
textcolor(MAGENTA + BLINK);
cprintf("SURE TO REMOVE (y/n)?");
ch=getche();
if(ch=='y'||ch=='Y')
{
ft=fopen("temp.txt","wb");
rewind(fp);
while(fscanf(fp,"%s %s %d",r.rt,r.rn,&r.cap)!=EOF)
{
if(strcmp(r.rn,rno)!=0)
fprintf(ft,"%s %s %d ",r.rt,r.rn,r.cap);
fflush(stdin);
}
fclose(ft);
fclose(fp);
remove("room.txt");
rename("temp.txt","room.txt");
}
}
/****************************OOPS! A REPETITION*****************************/
/*****************FUNCTION TO CHECK REPETITION OF INPUT DATA****************/
int rep(char sem,char br,char teach[25],char room[5],int i,int j)
{
FILE *fp;
int m;
struct cmp
{
char teach[25],room[5],sub[10];
}c;
if(br=='1' && sem=='1')
goto next11;
fp=fopen("sem1cse.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next11:
if(br=='1' && sem=='2')
goto next12;
fp=fopen("sem2cse.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next12:
if(br=='1' && sem=='3')
goto next13;
fp=fopen("sem3cse.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next13:
if(br=='1' && sem=='4')
goto next14;
fp=fopen("sem4cse.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next14:
if(br=='1' && sem=='5')
goto next15;
fp=fopen("sem5cse.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next15:
if(br=='1' && sem=='6')
goto next16;
fp=fopen("sem6cse.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next16:
if(br=='1' && sem=='7')
goto next17;
fp=fopen("sem7cse.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next17:
if(br=='1' && sem=='8')
goto next18;
fp=fopen("sem8cse.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next18:
if(br=='2' && sem=='1')
goto next21;
fp=fopen("sem1ece.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next21:
if(br=='2' && sem=='2')
goto next22;
fp=fopen("sem2ece.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next22:
if(br=='2' && sem=='3')
goto next23;
fp=fopen("sem3ece.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next23:
if(br=='2' && sem=='4')
goto next24;
fp=fopen("sem4ece.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next24:
if(br=='2' && sem=='5')
goto next25;
fp=fopen("sem5ece.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next25:
if(br=='2' && sem=='6')
goto next26;
fp=fopen("sem6ece.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next26:
if(br=='2' && sem=='7')
goto next27;
fp=fopen("sem7ece.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next27:
if(br=='2' && sem=='8')
goto next28;
fp=fopen("sem8ece.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next28:
if(br=='3' && sem=='1')
goto next31;
fp=fopen("sem1civ.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next31:
if(br=='3' && sem=='2')
goto next32;
fp=fopen("sem2civ.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next32:
if(br=='3' && sem=='3')
goto next13;
fp=fopen("sem3civ.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next33:
if(br=='3' && sem=='4')
goto next34;
fp=fopen("sem4civ.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (1);
}
fclose(fp);
next34:
if(br=='3' && sem=='5')
goto next35;
fp=fopen("sem5civ.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next35:
if(br=='3' && sem=='6')
goto next36;
fp=fopen("sem6civ.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next36:
if(br=='3' && sem=='7')
goto next37;
fp=fopen("sem7civ.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next37:
if(br=='3' && sem=='8')
goto next38;
fp=fopen("sem8civ.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next38:
if(br=='4' && sem=='1')
goto next41;
fp=fopen("sem1che.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next41:
if(br=='4' && sem=='2')
goto next42;
fp=fopen("sem2che.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next42:
if(br=='4' && sem=='3')
goto next43;
fp=fopen("sem3che.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next43:
if(br=='4' && sem=='4')
goto next44;
fp=fopen("sem4che.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next44:
if(br=='4' && sem=='5')
goto next45;
fp=fopen("sem5che.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next45:
if(br=='4' && sem=='6')
goto next46;
fp=fopen("sem6che.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next46:
if(br=='4' && sem=='7')
goto next47;
fp=fopen("sem7che.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next47:
if(br=='4' && sem=='8')
goto next48;
fp=fopen("sem8che.txt","r");
for(m=0;m<=i+j;m++)
fscanf(fp,"%s %s %s",c.teach,c.sub,c.room);
if(strcmp(c.teach,teach)==0)
{
return (1);
}
if(strcmp(c.room,room)==0)
{
return (2);
}
fclose(fp);
next48:
return (0);
}
/******************************WHICH SEMESTER?******************************/
/***************************FUNCTION FOR SEMESTER***************************/
char semester()
{
char ch;
framei();
gotoxy(29,4);
textcolor(RED+BLINK);
cprintf("SEMESTER");
gotoxy(25,7);
textcolor(GREEN);
cprintf("1.SEMESTER");
gotoxy(25,8);
cprintf("2.SEMESTER");
gotoxy(25,9);
cprintf("3.SEMESTER");
gotoxy(25,10);
cprintf("4.SEMESTER");
gotoxy(25,11);
cprintf("5.SEMESTER");
gotoxy(25,12);
cprintf("6.SEMESTER");
gotoxy(25,13);
cprintf("7.SEMESTER");
gotoxy(25,14);
cprintf("8.SEMESTER");
textcolor(MAGENTA);
gotoxy(27,19);
cprintf("ENTER CHOICE:");
ch=getche();
return(ch);
}
/***************************WHICH BRANCH?*********************************/
/************************SELECTION OF BRANCH******************************/
char branch()
{
char ch;
framei();
gotoxy(31,4);
textcolor(RED+BLINK);
cprintf("BRANCH");
gotoxy(25,7);
textcolor(GREEN);
cprintf("1.COMPUTER SCIENCE");
gotoxy(25,9);
cprintf("2.ELECTRONICS");
gotoxy(25,11);
cprintf("3.CIVIL");
gotoxy(25,13);
cprintf("4.CHEMICAL");
textcolor(MAGENTA);
gotoxy(27,19);
cprintf("ENTER CHOICE:");
ch=getche();
return(ch);
}
/***************************THE COLLECTION**********************************/
/**************************THE MAIN FUNCTION********************************/
void main()
{
char ch='a',sem,br;
clrscr();
first();
while(ch!='0')
{
ch=file();
textcolor(WHITE);
switch (ch)
{
case '0':
break;
case '1':
teacheri();
break;
case '2':
roomi();
break;
case '3':
teacherr ();
break;
case '4':
roomr();
break;
case '5':
frame();
teacher();
getch();
break;
case '6':
frame();
room();
getch();
break;
case '7':
sem=semester();
br=branch();
timetablei(sem,br);
break;
case '8':
sem=semester();
br=branch();
timetable(sem,br);
break;
default:
textcolor(RED+BLINK);
gotoxy(30,10);
cprintf("WRONG CHOICE!!!");
getch();
break;
}
}
}
/**************************************************************************/
/********************************THE END***********************************/
/**************************************************************************/
program based on POLYGON CLIPPING
POLYGON CLIPPING
#include
#include
#include
int n,p,x,y,i,j;
int xwmin,ywmin,xwmax,ywmax;
int x1,y1,x2,y2,xmax,ymax;
float m;
char flag;
float dy,dx;
main()
{int gd,gm;
int a[10][10],b[10][10],c[10][10],d[10][10],e[10][10];
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"d:\\tc\\bgi");
printf("\n\n\tEnter the no. of edges of polygon : ");
scanf("%d",&n);
printf("\n\n\tEnter the cordinates of polygon :\n\n\n ");
for(i=0;i {
printf("\tX%d Y%d : ",i,i);
scanf("%d %d",&a[i][0],&a[i][1]); }
a[n][0]=a[0][0];
a[n][1]=a[0][1];
printf("\n\tEnter the co_ordinates of window :\n ");
printf("\n\txwmin , ywmin : ");
scanf("%d %d",&xwmin,&ywmin);
printf("\n\txwmax , ywmax : ");
scanf("%d %d",&xwmax,&ywmax);
xmax = 640; ymax = 480;
cleardevice();
setcolor(35);
for(i=0;i line(a[i][0],ymax-a[i][1],a[i+1][0],ymax-a[i+1][1]);
rectangle(xwmin,ymax-ywmin,xwmax,ymax-ywmax);
getch();
setcolor(35);
clip_left(a,b);
clip_right(b,c);
clip_bottom(c,d);
clip_top(d,e);
cleardevice();
setcolor(63);
for(i=0;i { line(e[i][0],ymax-e[i][1],e[i+1][0],ymax-e[i+1][1]); }
getch();
}/*-main()-*/
clip_left(int a[10][10], int b[10][10])
{p=0;flag=0;m=0;
for(i=0;i { dy=a[i+1][1]-a[i][1];
dx=a[i+1][0]-a[i][0];
if((dx!=0)&&(dy!=0))
{m=(dy/dx);}
if((a[i][0]=xwmin) ) flag=0;
if((a[i][0]>=xwmin)&&(a[i+1][0]>=xwmin)) flag=1;
if((a[i][0]>=xwmin)&&(a[i+1][0] if((a[i][0] switch(flag)
{
case 0 :x=xwmin;
if(dy!=0)
y=(int)(a[i][1]+m*(x-a[i][0]));
else
y=a[i][1];
b[p][0]=x;
b[p][1]=y;
p++;
b[p][0]=a[i+1][0];
b[p][1]=a[i+1][1];
p++;
break;
case 1 : b[p][0]=a[i+1][0];
b[p][1]=a[i+1][1];
p++;
break;
case 2: x=xwmin;
if(dy!=0)
y=(int)(a[i][1]+m*(x-a[i][0]));
else
y=a[i][1];
b[p][0]=x;
b[p][1]=y;
p++;
}}
b[p][0]=b[0][0];
b[p][1]=b[0][1];
cleardevice();
setcolor(35);
rectangle(xwmin,ymax-ywmin,xwmax,ymax-ywmax);
setcolor(63);
for(i=0;i {
line(b[i][0],ymax-b[i][1],b[i+1][0],ymax-b[i+1][1]);
getch();
}
getch();}
clip_right(int b[10][10],int c[10][10])
{
n=p; p=0; m=0;
for(i=0;i { dy=b[i+1][1]-b[i][1];
dx=b[i+1][0]-b[i][0];
if((dx!=0)&&(dy!=0))
{m=(dy/dx);}
if((b[i][0]>xwmax)&&(b[i+1][0]<=xwmax) ) flag=0;
if((b[i][0]<=xwmax)&&(b[i+1][0]<=xwmax) ) flag=1;
if((b[i][0]<=xwmax)&&(b[i+1][0]>xwmax) ) flag=2;
if((b[i][0]>xwmax)&&(b[i+1][0]>xwmax) ) flag=3;
switch(flag)
{
case 0 : x=xwmax;
if(dy!=0)
y=(int)(b[i][1]+m*(x-b[i][0]));
else
y=b[i][1];
c[p][0]=x;
c[p][1]=y;
p++;
c[p][0]=b[i+1][0];
c[p][1]=b[i+1][1];
p++;
break;
case 1 : c[p][0]=b[i+1][0];
c[p][1]=b[i+1][1];
p++;
break;
case 2 : x=xwmax;
if(dy!=0)
y=(int)(b[i][1]+m*(x-b[i][0]));
else
y=b[i][1];
c[p][0]=x;
c[p][1]=y;
p++;}}
c[p][0]=c[0][0];
c[p][1]=c[0][1];
cleardevice();setcolor(35);
rectangle(xwmin,ymax-ywmin,xwmax,ymax-ywmax);
setcolor(63);
for(i=0;i {
line(c[i][0],ymax-c[i][1],c[i+1][0],ymax-c[i+1][1]);
getch();
}
getch();}
clip_bottom(int c[10][10],int d[10][10])
{
n=p; p=0; m=0;
for(i=0;i {
dy=c[i+1][1]-c[i][1];
dx=c[i+1][0]-c[i][0];
if((dx!=0)&&(dy!=0))
{
m=(dy/dx);
}
if((c[i][1]=ywmin) ) flag=0;
if((c[i][1]>=ywmin)&&(c[i+1][1]>=ywmin) ) flag=1;
if((c[i][1]>=ywmin)&&(c[i+1][1] if((c[i][1] switch(flag)
{
case 0 : y=ywmin;
if(dx!=0)
x=abs((int)(c[i][0]+(1/m)*(y-c[i][1])));
else
x=c[i][0];
d[p][0]=x;
d[p][1]=y;
p++;
d[p][0]=c[i+1][0];
d[p][1]=c[i+1][1];
p++;
break;
case 1 : d[p][0]=c[i+1][0];
d[p][1]=c[i+1][1];
p++;
break;
case 2 : y=ywmin;
if(dx!=0)
x=abs((int)(c[i][0]+(1/m)*(y-c[i][1])));
else
x=c[i][0];
d[p][0]=x;
d[p][1]=y;
p++;
}}
d[p][0]=d[0][0];
d[p][1]=d[0][1];
cleardevice();
setcolor(35);
rectangle(xwmin,ymax-ywmin,xwmax,ymax-ywmax);
setcolor(63);
for(i=0;i {
line(d[i][0],ymax-d[i][1],d[i+1][0],ymax-d[i+1][1]);
getch();
}getch();}
clip_top(int d[10][10],int e[10][10])
{ n=p;
p=0;
for(i=0;i { dy=d[i+1][1]-d[i][1];
dx=d[i+1][0]-d[i][0];
if((dx!=0)&&(dy!=0))
{m=(dy/dx);}
if((d[i][1]>ywmax)&&(d[i+1][1]<=ywmax) ) flag=0;
if((d[i][1]<=ywmax)&&(d[i+1][1]<=ywmax) ) flag=1;
if((d[i][1]<=ywmax)&&(d[i+1][1]>ywmax) ) flag=2;
if((d[i][1]>ywmax)&&(d[i+1][1]>ywmax) ) flag=3;
switch(flag)
{ case 0 : y=ywmax;
if(dx!=0)
x=abs((int)(d[i][0]+(1/m)*(y-d[i][1])));
else
x=d[i][0];
e[p][0]=x;
e[p][1]=y;
p++;
e[p][0]=d[i+1][0];
e[p][1]=d[i+1][1];
p++;
break;
case 1 : e[p][0]=d[i+1][0];
e[p][1]=d[i+1][1];
p++;
break;
case 2 : y=ywmax;
if(dx!=0)
x=abs((int)(d[i][0]+(1/m)*(y-d[i][1])));
else
x=d[i][0];
e[p][0]=x;
e[p][1]=y;
p++;}}
e[p][0]=e[0][0];
e[p][1]=e[0][1];
cleardevice();
setcolor(35);
rectangle(xwmin,ymax-ywmin,xwmax,ymax-ywmax);
setcolor(63);
for(i=0;i {line(e[i][0],ymax-e[i][1],e[i+1][0],ymax-e[i+1][1]);
getch();}
getch(); getch();
}
/***************OUTPUT*****************/
Enter the co ordinate (left,top) of windows:50,50
Enter the co ordinate (right,bottom)of windows:25,25
Enter the no. of vertex of polgon:3
Enter the vertex of point1 :-30,15
Enter the vertex of point2 :-50,15
Enter the vertex of point3 :-35,65
*********************************************************************************
NOTE THAT O/P IS graphical representation please check it on turbo c++ s/w
#include
#include
#include
int n,p,x,y,i,j;
int xwmin,ywmin,xwmax,ywmax;
int x1,y1,x2,y2,xmax,ymax;
float m;
char flag;
float dy,dx;
main()
{int gd,gm;
int a[10][10],b[10][10],c[10][10],d[10][10],e[10][10];
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"d:\\tc\\bgi");
printf("\n\n\tEnter the no. of edges of polygon : ");
scanf("%d",&n);
printf("\n\n\tEnter the cordinates of polygon :\n\n\n ");
for(i=0;i
printf("\tX%d Y%d : ",i,i);
scanf("%d %d",&a[i][0],&a[i][1]); }
a[n][0]=a[0][0];
a[n][1]=a[0][1];
printf("\n\tEnter the co_ordinates of window :\n ");
printf("\n\txwmin , ywmin : ");
scanf("%d %d",&xwmin,&ywmin);
printf("\n\txwmax , ywmax : ");
scanf("%d %d",&xwmax,&ywmax);
xmax = 640; ymax = 480;
cleardevice();
setcolor(35);
for(i=0;i
rectangle(xwmin,ymax-ywmin,xwmax,ymax-ywmax);
getch();
setcolor(35);
clip_left(a,b);
clip_right(b,c);
clip_bottom(c,d);
clip_top(d,e);
cleardevice();
setcolor(63);
for(i=0;i { line(e[i][0],ymax-e[i][1],e[i+1][0],ymax-e[i+1][1]); }
getch();
}/*-main()-*/
clip_left(int a[10][10], int b[10][10])
{p=0;flag=0;m=0;
for(i=0;i
dx=a[i+1][0]-a[i][0];
if((dx!=0)&&(dy!=0))
{m=(dy/dx);}
if((a[i][0]
if((a[i][0]>=xwmin)&&(a[i+1][0]>=xwmin)) flag=1;
if((a[i][0]>=xwmin)&&(a[i+1][0]
{
case 0 :x=xwmin;
if(dy!=0)
y=(int)(a[i][1]+m*(x-a[i][0]));
else
y=a[i][1];
b[p][0]=x;
b[p][1]=y;
p++;
b[p][0]=a[i+1][0];
b[p][1]=a[i+1][1];
p++;
break;
case 1 : b[p][0]=a[i+1][0];
b[p][1]=a[i+1][1];
p++;
break;
case 2: x=xwmin;
if(dy!=0)
y=(int)(a[i][1]+m*(x-a[i][0]));
else
y=a[i][1];
b[p][0]=x;
b[p][1]=y;
p++;
}}
b[p][0]=b[0][0];
b[p][1]=b[0][1];
cleardevice();
setcolor(35);
rectangle(xwmin,ymax-ywmin,xwmax,ymax-ywmax);
setcolor(63);
for(i=0;i {
line(b[i][0],ymax-b[i][1],b[i+1][0],ymax-b[i+1][1]);
getch();
}
getch();}
clip_right(int b[10][10],int c[10][10])
{
n=p; p=0; m=0;
for(i=0;i
dx=b[i+1][0]-b[i][0];
if((dx!=0)&&(dy!=0))
{m=(dy/dx);}
if((b[i][0]>xwmax)&&(b[i+1][0]<=xwmax) ) flag=0;
if((b[i][0]<=xwmax)&&(b[i+1][0]<=xwmax) ) flag=1;
if((b[i][0]<=xwmax)&&(b[i+1][0]>xwmax) ) flag=2;
if((b[i][0]>xwmax)&&(b[i+1][0]>xwmax) ) flag=3;
switch(flag)
{
case 0 : x=xwmax;
if(dy!=0)
y=(int)(b[i][1]+m*(x-b[i][0]));
else
y=b[i][1];
c[p][0]=x;
c[p][1]=y;
p++;
c[p][0]=b[i+1][0];
c[p][1]=b[i+1][1];
p++;
break;
case 1 : c[p][0]=b[i+1][0];
c[p][1]=b[i+1][1];
p++;
break;
case 2 : x=xwmax;
if(dy!=0)
y=(int)(b[i][1]+m*(x-b[i][0]));
else
y=b[i][1];
c[p][0]=x;
c[p][1]=y;
p++;}}
c[p][0]=c[0][0];
c[p][1]=c[0][1];
cleardevice();setcolor(35);
rectangle(xwmin,ymax-ywmin,xwmax,ymax-ywmax);
setcolor(63);
for(i=0;i {
line(c[i][0],ymax-c[i][1],c[i+1][0],ymax-c[i+1][1]);
getch();
}
getch();}
clip_bottom(int c[10][10],int d[10][10])
{
n=p; p=0; m=0;
for(i=0;i
dy=c[i+1][1]-c[i][1];
dx=c[i+1][0]-c[i][0];
if((dx!=0)&&(dy!=0))
{
m=(dy/dx);
}
if((c[i][1]
if((c[i][1]>=ywmin)&&(c[i+1][1]>=ywmin) ) flag=1;
if((c[i][1]>=ywmin)&&(c[i+1][1]
{
case 0 : y=ywmin;
if(dx!=0)
x=abs((int)(c[i][0]+(1/m)*(y-c[i][1])));
else
x=c[i][0];
d[p][0]=x;
d[p][1]=y;
p++;
d[p][0]=c[i+1][0];
d[p][1]=c[i+1][1];
p++;
break;
case 1 : d[p][0]=c[i+1][0];
d[p][1]=c[i+1][1];
p++;
break;
case 2 : y=ywmin;
if(dx!=0)
x=abs((int)(c[i][0]+(1/m)*(y-c[i][1])));
else
x=c[i][0];
d[p][0]=x;
d[p][1]=y;
p++;
}}
d[p][0]=d[0][0];
d[p][1]=d[0][1];
cleardevice();
setcolor(35);
rectangle(xwmin,ymax-ywmin,xwmax,ymax-ywmax);
setcolor(63);
for(i=0;i {
line(d[i][0],ymax-d[i][1],d[i+1][0],ymax-d[i+1][1]);
getch();
}getch();}
clip_top(int d[10][10],int e[10][10])
{ n=p;
p=0;
for(i=0;i
dx=d[i+1][0]-d[i][0];
if((dx!=0)&&(dy!=0))
{m=(dy/dx);}
if((d[i][1]>ywmax)&&(d[i+1][1]<=ywmax) ) flag=0;
if((d[i][1]<=ywmax)&&(d[i+1][1]<=ywmax) ) flag=1;
if((d[i][1]<=ywmax)&&(d[i+1][1]>ywmax) ) flag=2;
if((d[i][1]>ywmax)&&(d[i+1][1]>ywmax) ) flag=3;
switch(flag)
{ case 0 : y=ywmax;
if(dx!=0)
x=abs((int)(d[i][0]+(1/m)*(y-d[i][1])));
else
x=d[i][0];
e[p][0]=x;
e[p][1]=y;
p++;
e[p][0]=d[i+1][0];
e[p][1]=d[i+1][1];
p++;
break;
case 1 : e[p][0]=d[i+1][0];
e[p][1]=d[i+1][1];
p++;
break;
case 2 : y=ywmax;
if(dx!=0)
x=abs((int)(d[i][0]+(1/m)*(y-d[i][1])));
else
x=d[i][0];
e[p][0]=x;
e[p][1]=y;
p++;}}
e[p][0]=e[0][0];
e[p][1]=e[0][1];
cleardevice();
setcolor(35);
rectangle(xwmin,ymax-ywmin,xwmax,ymax-ywmax);
setcolor(63);
for(i=0;i {line(e[i][0],ymax-e[i][1],e[i+1][0],ymax-e[i+1][1]);
getch();}
getch(); getch();
}
/***************OUTPUT*****************/
Enter the co ordinate (left,top) of windows:50,50
Enter the co ordinate (right,bottom)of windows:25,25
Enter the no. of vertex of polgon:3
Enter the vertex of point1 :-30,15
Enter the vertex of point2 :-50,15
Enter the vertex of point3 :-35,65
*********************************************************************************
NOTE THAT O/P IS graphical representation please check it on turbo c++ s/w
program for 2 pass assembler
/*Pass Assembler*/
#include
#include
#include
#include
#include
#include
void ShowPass2();
void ShowSymbol();
void ShowPass1();
void readword(void);
void ismot();
void issymbol();
void symbolpresent(char c[]);
void findtype(int );
void display();
void show(int);
void pass2();
struct mot
{
char mne[7];
int type; //type 1.IMPERATIVE 2.DECLARATIVE 3.DIRECTIVE
char op[5];
int len;
}m;
struct mot mtable[10]= {
{"LOAD",1,"08",1},
{"STORE",1,"05",1},
{"ADD",1,"12",1},
{"PRINT",1,"07",1},
{"DS",2,"DL#1",0},
{"DC",2,"DL#2",0},
{"START",3,"-",0},
{"EQU",3,"-",0},
{"ORIGIN",3,"-",0},
{"END",3,"-",0}
};
struct pass1
{
int LC;
char code1[10];
char code2[10];
}pa[25];
struct pa2
{
int LC;
char code1[10];
char code2[10];
}p2[25];
struct symtab
{
char symbol[15];
int address,length,OtherInfo;
}stab[20];
int index=0; //give last index of symtab
static int passindex=0;
int lc;
char word[30];
FILE *fs,*ft;
char ch;
void ShowSymbol()
{
int i;
printf("\n ***********SYMBOL TABLE***********");
gotoxy(2,3);
printf("symbol");
gotoxy(22,3);
printf("Address\n*********************************");
for(i=1;i<=index-1;i++)
{
gotoxy(4,4+i);
printf("%s",stab[i].symbol);
gotoxy(24,4+i);
printf("%d",stab[i].address);
}
printf("\n ****************************************");
}
void ShowMOT()
{
int i;
printf("\n**************MNEMOPNICS OPCODE TABLE***************");
gotoxy(2,3);
printf("MNEMONIC");
gotoxy(22,3);
printf("Type");
gotoxy(30,3);
printf("opcode");
gotoxy(40,3);
printf("Length");
printf("\n ******************************************************");
for(i=0;i<10;i++)
{
gotoxy(4,6+i);
printf("%s",mtable[i].mne);
gotoxy(24,6+i);
printf("%d",mtable[i].type);
gotoxy(33,6+i);
printf("%s",mtable[i].op);
gotoxy(43,6+i);
printf("%d",mtable[i].len);
}
printf("\n ******************************************************");
}
void ShowPass1()
{
int i;
clrscr();
printf("\n ******************PASS 1********************");
gotoxy(2,3);
printf("LC");
gotoxy(17,3);
printf("Opcode");
gotoxy(32,3);
printf("Operand");
printf("\n ***********************************");
for(i=0;i
gotoxy(4,5+i);
printf("%d",pa[i].LC);
gotoxy(19,5+i);
printf("%s",pa[i].code1);
gotoxy(34,5+i);
printf("%s",pa[i].code2);
}
printf("\n ***********************************");
}
void ShowPass2()
{
int i;
clrscr();
printf("\n ***************PASS 2********************");
gotoxy(2,3);
printf("LC");
gotoxy(17,3);
printf("Opcode");
gotoxy(32,3);
printf("Operand");
printf("\n ***********************************");
for(i=0;i
gotoxy(4,4+i);
printf("%d",p2[i].LC);
gotoxy(19,4+i);
printf("%s",p2[i].code1);
gotoxy(34,4+i);
printf("%s",p2[i].code2);
}
printf("\n ***********************************");
}
void main()
{
char fname[15];
int i;
clrscr();
printf("\n Enter the name of the file==>\t");
gets(fname);
if((fs=fopen(fname,"r"))==NULL)
{
printf("\nUnable TO Read This File.");
getch();
exit(1);
}
else
{
if((ft=fopen("output.asm","w"))==NULL)
{
printf("Unable TO Open File.");
getch();
fclose(fs);
exit(1);
}
do
{
printf(" ");
readword();
ismot();
}while(ch!=EOF);
pass2();
show(passindex);
display();
getch();
fclose(fs);
fclose(ft);
}
}
void readword(void)
{
int i;
i=0;
while((ch=fgetc(fs))!=' ')
{
if(ch==EOF ch=='\t' ch=='\n')
break;
if(ch==EOF && ch=='\t' && ch=='\n')
word[i++]=ch;
}
word[i]='\0';
}
void ismot()
{
int i,t,flag=0;
for(i=0;i<11;i++)
{
if((strcmpi(mtable[i].mne,word))==0)
{
flag=1;
switch(i)
{
case 0: //load
strcpy(pa[passindex].code1,mtable[i].op);
readword();
issymbol();
strcpy(pa[passindex].code2,word);
pa[++passindex].LC=pa[passindex-1].LC+mtable[i].len;
break;
case 1: //store
strcpy(pa[passindex].code1,mtable[i].op);
readword();
issymbol();
strcpy(pa[passindex].code2,word);
pa[++passindex].LC=pa[passindex-1].LC+mtable[i].len;
break;
case 2: //add
strcpy(pa[passindex].code1,mtable[i].op);
readword();
issymbol();
strcpy(pa[passindex].code2,word);
pa[++passindex].LC=pa[passindex-1].LC+mtable[i].len;
break;
case 3: //print
strcpy(pa[passindex].code1,mtable[i].op);
readword();
issymbol();
strcpy(pa[passindex].code2,word);
pa[++passindex].LC=pa[passindex++].LC=pa[passindex-1].LC+mtable[i].len;
lc=pa[passindex-1].LC;
break;
case 4: //DS
readword();
lc=atoi(word);
t=pa[passindex].LC+lc;
strcpy(pa[passindex].code1,mtable[i].op);
strcpy(pa[passindex].code2,strcat(word,"i"));
pa[++passindex].LC=t;
break;
case 5: //dc
readword();
strcpy(pa[passindex].code1,mtable[i].op);
strcpy(pa[passindex].code2,strcat(word,"i"));
lc=pa[passindex].LC;
pa[passindex++].LC=lc;
break;
case 6: //start
readword();
lc=atoi(word);
pa[passindex].LC=lc;
break;
case 7: //equ
readword();
issymbol();
readword();
readword();
for(i=0;i<=index;i++)
{
flag=0;
if(strcmpi(stab[i].symbol,"D")==0)
{
stab[i].address=lc+1;
break;
}
}
break;
case 8: //origin
readword();
issymbol();
readword();
readword();
pa[passindex].LC=lc+atoi(word);
break;
case 9: //end
break;
default:
break;
}
}
}
// getch();
if(flag==0)
issymbol();
}
void issymbol()
{
int i=0,flag;
//readword();
for(i=0;i<=index;i++)
{
flag=0;
if(strcmpi(stab[i].symbol,word)==0)
{
lc=stab[i].address;
flag=1;
break;
}
}
if(flag==0)
{
index++;
strcpy(stab[index].symbol,word);
stab[index].address=pa[passindex].LC;
}
}
void findtype(int n)
{
switch(n)
{
case 1: printf("\Imperative");
break;
case 2: printf("\Declarative");
break;
case 3: printf("\Directive");
break;
}
printf("%s",word);
}
void show(int n)
{
int i;
printf("\npassindex=%d",n);
for(i=0;i
printf("\n%d\t",pa[i].LC);
printf("%s\t",pa[i].code1);
printf("%s\t",pa[i].code2);
}
getch();
}
void pass2()
{
int i;
char ch[10];
for(i=0;i
p2[i].LC=pa[i].LC;
strcpy(p2[i].code1,pa[i].code1);
strcpy(p2[i].code2,pa[i].code2);
strcpy(ch,p2[i].code2);
symbolpresent(ch);
itoa(lc,p2[i].code2,10);
}
printf("\n PASS2");
for(i=0;i
printf("\n%d\t",p2[i].LC);
printf("%s\t",p2[i].code1);
printf("%s\t",p2[i].code2);
}
}
void symbolpresent(char c[])
{
int i=0;
for(i=0;i<=index;i++)
{
if(strcmpi(stab[i].symbol,c)==0)
{
lc=stab[i].address;
break;
}
}
}
void display()
{
clrscr();
ShowMOT();
getch();
clrscr();
ShowSymbol();
getch();
ShowPass1();
getch();
ShowPass2();
getch();
}
ASSEM.C
START 100
A DS 3
L1 LOAD B
ADD C
STORE D
D EQU A + 1
L2 PRINT D
ORIGIN A + 2
C DC 5
ORIGIN L2 + 1
B DC 19
OUTPUT
**************MNEMONICS OPCODE TABLE***************
Mnemonic Type Opcode Length
*********************************************************
LOAD 1 08 1
STORE 1 05 1
ADD 1 12 1
PRINT 1 07 1
DS 2 DL#1 0
DC 2 DL#2 0
START 3 -- 0
EQU 3 -- 0
ORIGIN 3 -- 0
END 3 -- 0
***************SYMBOL TABLE***************
Symbol Address
*********************************************
A 100
L1 103
B 103
C 104
D 101
*********************************************
********************PASS 1********************
LC OPCODE OPERAND
**********************************************
100 DL#1 3i
103 08 B
104 12 C
105 05 D
106 07 D
102 00 5i
107 00 19i
**********************************************
********************PASS 2********************
LC OPCODE OPERAND
**********************************************
103 08 103
104 12 104
105 05 101
106 07 101
**********************************************
Subscribe to:
Comments (Atom)
all other content`s to the next page
my phylosophy
- Black Hat Hacker
- virtual city, MH, India
- ۩۞۩ ♥ ۩۞۩ ♥ ۩۞۩ ♥ ۩۞۩ ♥ ۩۞۩ ♥ ۩۞۩ ♥ ۩۞۩ ♥ ۩۞۩ hi, gies i am fan of computer so, to share my knowledge. i made this blog with some reference: 1.www.mumbaihacker.com 2.www.redhacker.xm.com 3.www.onlinehackers.xm.com 4.www.rupeshhacktrix.blogspot.com ************************************ ® registered . ۩ orkut V.I.P account ۩ ۩۞۩ ♥ ۩۞۩ ♥ ۩۞۩ ♥ ۩۞۩ ♥ ۩۞۩ ♥ ۩۞۩ ♥ ۩۞۩ ♥ ۩۞۩ wєlcσмє тσ⋙ αcα∂ємy σƒ нαcking ⋘ ҳ̸Ҳ̸ҳ●๋• experience the difference ҳ̸Ҳ̸ҳ●๋•
