Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 

 
SOUTHERN RAILWAY (TRAIN DETAILS MANAGEMENT )

--------------------------------------------------------------------------------

Description : It is about the train details like adding a new train , its name,no. ect and reserving tickets ect,edit train details ect.

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<process.h>
#include<graphics.h>
#include<dos.h>

struct emp
{
char rno[10];
char tname[10];
char from[10];
char to[10];
int st;
}a;
struct emp1
{
char rno[10];
char tdate[8];
int st;
}b;

FILE *fp1,*fp2,*fp3;
char fname[20],fname1[20];
void add();
void edit();
void disp();
void dele();
void res();
void grap();
void main()
{

int ch=0,r1;
grap();
while(ch!=6)
{
clrscr();
printf("
SOUTHERN RAILWAYS");
printf("
^^^^^^^^^^^^^^^^^");
printf("

1.Add Train details");
printf("
2.Delete Train details");
printf("
3.Updata Train details");
printf("
4.Display List");
printf("
5.Reservation");
printf("
6.Exit");
printf("
");
printf("
Enter the choice : ");
scanf("%d",&ch);
switch(ch)
{
case 1:
add();
break;
case 2:

dele();
break;
case 3:
edit();
break;
case 4:
disp();
break;
case 5:
res();
break;
case 6:
exit(0);
}
}
}
void add()
{
char yesno='y';
clrscr();
fp1=fopen("rwl.dat","a");
// printf("ADD FILES");
while(yesno=='y'||yesno=='y')
{
printf("
SOUTHERN RAILWAYS");
printf("
^^^^^^^^^^^^^^^^^");
printf("
Enter the train Number :");
scanf("%s",a.rno);
printf("
Enter the Train name :");
scanf("%s",a.tname);
printf("
Enter the Arrival station :");
scanf("%s",a.from);
printf("
Enter the Departure station :");
scanf("%s",a.to);
printf("
Enter the Total Seats : ");
scanf("%d",&a.st);
fprintf(fp1,"%s %s %s %s %d<BR>,a.rno,a.tname,a.from,a.to,a.st);
printf("
do u want to continue[y/n]");
yesno=getchar();
fflush(stdin);
}

fclose(fp1);
}
void edit()
{
char empno1[4];
clrscr();
printf("
SOUTHERN RAILWAYS");
printf("
^^^^^^^^^^^^^^^^^");
printf("
Enter the train Number to edit :");
scanf("%s",empno1);
fp1=fopen("rwl.dat","r");
fp2=fopen("trwl.dat","w");
strcpy(fname,"rwl.dat");
strcpy(fname1,"trwl.dat");
while(!feof(fp1))
{
fscanf(fp1,"%s %s %s %s %d<BR>,a.rno,a.tname,a.from,a.to,&a.st);
// printf(" %s ",a.rno);
if(strcmp(a.rno,empno1)==0)
{
printf("
Enter the train Number :");
scanf("%s",a.rno);
printf("
Enter the Train Name :");
scanf("%s",a.tname);
printf("
Enter the Arrival station :");
scanf("%s",a.from);
printf("
Enter the Departure station :");
scanf("%s",a.to);
printf("
Enter the Total Seats :");
scanf("%d",&a.st);
fprintf(fp2,"%s %s %s %s %d<BR>,a.rno,a.tname,a.from,a.to,a.st);
// break;
}
else
fprintf(fp2,"%s %s %s %s %d<BR>,a.rno,a.tname,a.from,a.to,a.st);
}
fclose(fp1);
fclose(fp2);
unlink(fname);
rename(fname1,fname);

}

void disp()
{
clrscr();
printf("
SOUTHERN RAILWAYS");
printf("
^^^^^^^^^^^^^^^^^<BR>);
printf(" TRAIN-NO NAME DEP ARR SEATS<BR>);
printf(" -------- ---- ---- ----- ------<BR>);
fp1=fopen("rwl.dat","r");
while(!feof(fp1))
{
fscanf(fp1,"%s %s %s %s %d<BR>,a.rno,a.tname,a.from,a.to,&a.st);
printf(" %s %s %s %s %d<BR>,a.rno,a.tname,a.from,a.to,a.st);
}
fclose(fp1);
getch();
}

void dele()
{
char empno1[4];int i=0;
clrscr();
printf("
SOUTHERN RAILWAYS");
printf("
^^^^^^^^^^^^^^^^^");
printf("
Enter the train Number to delete :");
scanf("%s",empno1);
fp1=fopen("rwl.dat","r");
fp2=fopen("trwl.dat","w");
strcpy(fname,"rwl.dat");
strcpy(fname1,"trwl.dat");
while(!feof(fp1))
{
fscanf(fp1,"%s %s %s %s %d<BR>,a.rno,a.tname,a.from,a.to,&a.st);
if(strcmp(a.rno,empno1)!=0)
{
fprintf(fp2,"%s %s %s %s %d<BR>,a.rno,a.tname,a.from,a.to,a.st);
}
else
{ i=1;
printf("
TRAIN DETAILS DELETED SUCCESSFULLY ");

}
}
if(i==0)
{
printf("
SORRY -> INVALID TRAIN NUMBER ");

}
fclose(fp1);
fclose(fp2);
unlink(fname);
rename(fname1,fname);
getch();

}

void res()
{
char empno1[4],tdate[8];
int i=0,n;
clrscr();
printf("
SOUTHERN RAILWAYS");
printf("
^^^^^^^^^^^^^^^^^");
printf("
Enter the train Number :");
scanf("%s",empno1);
printf("
Enter the Date :");
scanf("%s",tdate);
{
fp1=fopen("res.dat","r");
fp2=fopen("trwl.dat","w");
strcpy(fname,"res.dat");
strcpy(fname1,"trwl.dat");
while(!feof(fp1))
{
fscanf(fp1,"%s %s %d<BR>,b.rno,b.tdate,&b.st);
if((strcmp(b.rno,empno1)==0) && (strcmp(b.tdate,tdate)==0))
{
i=1;
printf("
Total seats Available : ");
printf("%d",b.st);
printf("
Enter the Number of Seats:");
scanf("%d",&n);
if(n > b.st)
{
printf("
SORRY,LIMIT EXCEEDED ");
}
else
{ b.st=b.st-n;
printf("
TICKETS BOOKED SUCCESSFULLY ");
}
fprintf(fp2,"%s %s %d<BR>,b.rno,b.tdate,b.st);
}
else
{
fprintf(fp2,"%s %s %d<BR>,b.rno,b.tdate,b.st);
}
}
rewind(fp1);
fclose(fp1);
fclose(fp2);
// printf(" %d ",i);
// getch();
if (i==1)
{
getch();
unlink(fname);
rename(fname1,fname);
}

}

if (i==0)
{
fp1=fopen("rwl.dat","r");
while(!feof(fp1))
{
fscanf(fp1,"%s %s %s %s %d<BR>,a.rno,a.tname,a.from,a.to,&a.st);
// printf("%s",a.rno);
if(strcmp(a.rno,empno1)==0)
{ i= 2;
n=a.st;
}
}
fclose(fp1);
if (i==2)
{
fp1=fopen("res.dat","a");
{
/* printf("
Enter the train Number -> ");
scanf("%s",b.rno);
printf("
Enter the Date -> ");
scanf("%s",b.tdate); */
strcpy(b.rno,empno1);
strcpy(b.tdate,tdate);
printf("
Total Seats Available : %d ",n);
printf("
Enter Number of seats : ");
scanf("%d",&b.st);
if( n < b.st)
{
printf("
SORRY,LIMIT EXCEEDED ");
b.st=n;
}
else
{b.st=n-b.st;
printf("
TICKETS BOOKED SUCCESSFULLY ");
}
fprintf(fp1,"%s %s %d<BR>,b.rno,b.tdate,b.st);
//fflush(stdin);
}
rewind(fp1);
fclose(fp1);
getch();
}
else
{
clrscr();
printf("
SOUTHERN RAILWAYS");
printf("
^^^^^^^^^^^^^^^^^");
printf("
Enter the Valid Train Number ");
getch();
}
}
}

void grap()
{
int gdriver = EGA, gmode = EGAHI;
int bkcol, maxcolor, x, y,i;
char msg[80];

/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");

//' settextstyle(3,0,12);
// outtextxy(200,20,"RMD");


for (i=1;i<=70;i++)
{
setcolor(7);
circle(i,20+i,i);
circle(i,220-i,i);
circle(620-i,220-i,i);
circle(620-i,20+i,i);
delay(100);

}

settextstyle(3,0,12);
outtextxy(200,20,"RMD");
settextstyle(3,0,4);
outtextxy(155,160,"ENGINEERNG COLLEGE");
delay(3000);
for (i=1;i<=90;i++)
{
setcolor(1);
line(155,60+i,470,60+i);
line(155,200-i,470,200-i);
delay(20);
setcolor(0);
line(155,60+i,470,60+i);
line(155,200-i,470,200-i);

}
for (i=1;i<=270;i++)
{
setcolor(1);
line(312-i,10,312-i,250);
line(309+i,10,309+i,250);
delay(10);
setcolor(0);
line(312-i,10,312-i,250);
line(309+i,10,309+i,250);

}
setcolor(15);
settextstyle(3,0,4);
outtextxy(200,100,"WELCOME TO");
settextstyle(3,0,4);
outtextxy(90,150,"RAILWAY TICKET RESERVATION");
delay(1000);
getch();
closegraph();
}

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved © copyright 123ENG