Add to Favorites    Make Home Page 8483 Online  
 Language Categories  
 Our Services  

Home » C Home » C on Unix Home » SOUTHERN RAILWAY (TRAIN DETAILS MANAGEMENT )

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title SOUTHERN RAILWAY (TRAIN DETAILS MANAGEMENT )
Author RAMAKRISHNAN.N
Author Email ramakrishnan122001 [at] yahoo.co.in
Description It is about the train details like adding a new train , its
name,no. ect and reserving tickets ect,edit train details ect.

Category C » C on Unix
Hits 32905
Code Select and Copy the Code
#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 ",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 ",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 ",a.rno,a.tname,a.from,a.to,a.st); // break; } else fprintf(fp2,"%s %s %s %s %d ",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(" ^^^^^^^^^^^^^^^^^ "); printf(" TRAIN-NO NAME DEP ARR SEATS "); printf(" -------- ---- ---- ----- ------ "); fp1=fopen("rwl.dat","r"); while(!feof(fp1)) { fscanf(fp1,"%s %s %s %s %d ",a.rno,a.tname,a.from,a.to,&a.st); printf(" %s %s %s %s %d ",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 ",a.rno,a.tname,a.from,a.to,&a.st); if(strcmp(a.rno,empno1)!=0) { fprintf(fp2,"%s %s %s %s %d ",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 ",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 ",b.rno,b.tdate,b.st); } else { fprintf(fp2,"%s %s %d ",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 ",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 ",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(); }

Related Source Codes

Script Name Author
The Game Opposite as seen on Nokia 2300 Mobile Manikanta
RECURSIVE BALANCED QUICK SORT ashish
Radix Sort ashish
Change your mouse pointer Ashim
The blinking star Shashank
Data Validation Crylittlebaby
To search a file by giving file type like mp3 or mpeg or doc Prashanth SR
Menus Demonstration B.Chidhambaram
Employee Database Project Using C. Reenku Raman Nayak
Creating a Lexical Analyzer in c fahad bader al-buhairi դ ? ??
Calendar Program Omkar & Devendra
Stop double Process for start in C Cedrik Jurak
Stop double Process for start in C Cedrik Jurak
Time Scheduler Atiq Anwar
A timepass game between atmost two players Rahul Roy

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions
Copyright ©2003-2017 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=930


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review