Académique Documents
Professionnel Documents
Culture Documents
#include <stdio.h>
int main(void)
{
int id;
FILE *fp,*ft;
char another,choice;
Employee emp;
char fname[20];
char lname[20];
long int recsize;
fp=fopen("EMP.DAT","rb+");
if(fp==NULL)
{
fp=fopen( "EMP.DAT","wb+");
if(fp==NULL)
{
printf("
Can't Open File");
exit();
}
}
recsize=sizeof(emp);
while(1)
{
printf("
1.Add Records
2.Delete Records
3.Modify Records
4.List
Records
5.Exit");
printf("
break;
case '2':
another='Y';
while(another=='Y'|| another=='y')
{
printf("
Enter the id of the employee to be deleted : ");
scanf("%d",&id);
ft=fopen("TEMP.DAT","wb");
rewind(fp);
while(fread(&emp,recsize,1,fp)==1)
{
if(strcmp(emp.id,id)!=0)
fwrite(&emp,recsize,1,ft);
}
fclose(fp);
fclose(ft);
remove("EMP.DAT");
rename("TEMP.DAT","EMP.DAT");
fp=fopen("EMP.DAT","rb+");
printf("Delete another Record(Y/N): ");
fflush(stdin);
another=getchar();
}
break;
case '3':
another='Y';
while(another=='Y'|| another=='y')
{
printf("
Enter name of employee to modify : ");
scanf("%s",emp.fname);
rewind(fp);
while(fread(&emp,recsize,1,fp)==1)
{
if(strcmp(emp.id,id)==0)
{
printf("
Enter new fname,new lname,age,basic
salary,joining_date,subject taken and last education : ");
scanf("%s%s%d%f%s%s%s",emp.fname,emp.lname,&emp.age,&emp.bsal,emp.join_dat
e,emp.sub_taken,emp.last_edu);
fseek(fp,-recsize,SEEK_CUR);
fwrite(&emp,recsize,1,fp);
break;
}
}
printf("
Want to Modify another record(Y/N): ");
fflush(stdin);
another=getchar();
}
break;
case '4':
rewind(fp);
while(fread(&emp,recsize,1,fp)==1)
printf("
%s %s %d
%g",emp.fname,emp.lname,emp.age,emp.bsal,emp.join_date,emp.last_edu,emp.su
b_taken);
break;
case '5':
fclose(fp);
exit();
}
}
}
SLAM BOOK ,YOU CAN ADD UR FRIENDS BIODATA.
#include<graphics.h>
#include<conio.h>
#include<dos.h>
#include<process.h>
#include<stdio.h>
#include<string.h>
union REGS i,o;
void main()
{
int driver,mode,x,y,but,z; //intialitions of all variables
and
functions
driver = DETECT;
int initmouse(); // to load mouse driver
int resmptr(int p,int q,int r,int s); //restric mouse pointer
within
boundry
int showmptr(); // shows mouse pointer
int getmpos(int *t,int *u, int *v); // captures the current
position of mouse pointer
initgraph(&driver, &mode, "C:\tc\bgi"); //initialize graphics
mode
nare :
setcolor(YELLOW);
outtextxy(250,10,"MY SLAM BOOK");
setcolor(GREEN);
outtextxy(70,70,"I'm sure you'll enjoy filling my slam book as
much
as");
outtextxy(80,80,"I will enjoy reading about you later.");
setcolor(LIGHTGREEN);
rectangle(30,30,635,460);
rectangle(200,100,380,115);
outtextxy(210,105," 1.Add Records");
rectangle(200,120,380,135);
outtextxy(210,125," 2.List Records");
rectangle(200,140,380,155);
outtextxy(210,145," 3.Modify Records");
rectangle(200,160,380,175);
outtextxy(210,165," 4.Delete Records");
rectangle(200,180,300,195);
outtextxy(210,185," 0.Exit");
if(initmouse() == 0)
{ // load mouse
driver if not
closegraph(); // exit the program
restorecrtmode();
printf("
Mouse driver is not loaded");
exit(1);
}
showmptr();
resmptr(30,30,635,460);
setcolor(RED);
outtextxy(70,310,"# Press Add Records button to add a record");
outtextxy(70,330,"# Press List Records button to list records");
outtextxy(70,350,"# Press Modify Records button to modify any
record");
outtextxy(70,370,"# Press Delete Records button to delete
record");
setcolor(13);
setcolor(YELLOW);
outtextxy(200,440,"Press any key to exit program");
FILE *fp,*ft;
char another,choice,ch;
struct frien
{
char urname[40];
char emailid[40];
long int mobno;
};
struct frien f;
char friname[40];
long int recsize;
fp=fopen("FRE.DAT","rb+");
if(fp==NULL)
{
fp=fopen("FRE.DAT","wr+");
if(fp==NULL)
{
puts("Cannot open file");
exit(0);
}
}
recsize=sizeof(f);
while(!kbhit()) // loop until
any
key is pressed
{
getmpos(&but,&x,&y); // capture
current
pointer position when click event happens
if(x>=200 && x<=380 && y>=100 && y<=115 && (but & 1) == 1) //
and
switch to that if loop
{
clrscr();
setfillstyle(SOLID_FILL,BLACK);
floodfill(0,0,BLACK);
gotoxy(100,100);
printf("
HELLO FRIEND ");
fseek(fp,0,SEEK_END);
another='y';
while(another=='y')
{
printf("
Enter ur Name:-");
scanf("%s",f.urname);
printf("
Enter ur Mobileno:-");
scanf("%ld",&f.mobno);
fwrite(&f,recsize,1,fp);
printf("
} //first if ends
else if(x>=200 && x<=380 && y>=120 && y<=135 && (but & 1) == 1)
{
clrscr();
setfillstyle(SOLID_FILL,BLACK);
floodfill(0,0,BLACK);
outtextxy(100,370,"THESE ARE MY BEST FRIENDS,I LOVE THEM VERY
MUCH");
outtextxy(100,390,"PRESS n TO GO TO MAIN SCREEN");
fseek(fp,0,SEEK_SET);
printf("NAME EMAILID MOBILENO ");
while(fread(&f,recsize,1,fp)==1)
{
printf("
");
printf("%s %s %ld ",f.urname,f.emailid,f.mobno);
printf("
");
}
if(getche()=='n')
{
fflush(stdin);
clrscr();
setfillstyle(SOLID_FILL,BLACK);
floodfill(0,0,BLACK);
goto nare;
}
} //second if ends
else if(x>=200 && x<=380 && y>=140 && y<=155 && (but & 1) == 1)
{
clrscr();
setfillstyle(SOLID_FILL,BLACK);
floodfill(0,0,BLACK);
setcolor(YELLOW);
printf("HELLO");
another='y',ch='y';
while(another=='y')
{
printf("
Enter name of friend to modify:-");
scanf("%s",friname);
if(strcmp(f.urname,friname)==0)
{
printf("
U r stored in my book");
printf("
Enter ur Name:-");
scanf("%s",f.urname);
printf("
Enter ur Mobileno:-");
scanf("%d",&f.mobno);
fseek(fp,-recsize,SEEK_CUR);
fwrite(&f,recsize,1,fp);
printf("
else if(x>=200 && x<=380 && y>=160 && y<=175 && (but & 1) == 1)
{
clrscr();
setfillstyle(SOLID_FILL,BLACK);
floodfill(0,0,BLACK);
another='y';
while(another=='y')
{
printf("
goto sid;
}
ft=fopen("TEMP.DAT","wb");
rewind(fp);
while(fread(&f,recsize,1,fp)==1)
{
if(strcmp(f.urname,friname)!=0)
fwrite(&f,recsize,1,ft);
}
fclose(fp);
fclose(ft);
printf("
else if(x>=200 && x<=300 && y>=180 && y<=195 && (but & 1) == 1)
{
clrscr();
setfillstyle(SOLID_FILL,BLACK);
floodfill(0,0,BLACK);
setcolor(YELLOW);
outtextxy(120,100,"THANKING YOU FOR USING MY SLAM BOOK");
getch();
fclose(fp);
exit(0);
}// fifth if ends
# include <stdio.h>
main()
{
FILE *fp1;
char ch;
fp1=fopen("source.c","r");
while((ch=fgetc(fp1))!=EOF)
printf("%c",ch);
fclose(fp1);
}
Complete banking system program.
//bank.c
/
*==============================================================
==========
=
HEADER FILES
===============================================================
===========
=*/
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <dos.h>
#include<string.h>
#include <graphics.h>
#define LEN 100
/
*==============================================================
=========
FUNCTIONS THAT ARE USED IN PROGRAM
===============================================================
=========*/
/
*==============================================================
==========
===
INITIAL STRUCTURE WHICH USED FOR STORE DATA OF NEW ACCOUNT
IN INITIAL.REC FILE AND RETURN DATA FROM INITIAL FILE
===============================================================
===========
=*/
struct initial
{
int accno; //account no.
char name[25];
char fName[25];
char address[60];
double balance;
};
struct initial ini[LEN];
/
*==============================================================
==========
==
ACCOUNT STRUCTURE WHICH IS USED FOR STORE DATA OF ACCOUNTS
IN ACCOUNT.REC FILE AND RETURN DATA FROM ACCOUNT.REC FILE
===============================================================
===========
=*/
struct account
{
int accno ; //account no.
char type[10] ; // Cheque or Cash
int dd, mm, yy ; // Date
char tran ; // Deposit or Withdraw
double interest, amount, balance ;
};
struct account acc[LEN];
/
*==============================================================
==========
====
FUNCTION THAT IS USED FOR CLEAR A LINE
===============================================================
===========
==*/
void clear(int col, int row)
{
int i;
for (i=col; i<=78; i++) //print spaces in one line
{
gotoxy(i,row) ;
printf(" ") ;
}
}
/
*==============================================================
==========
==
FUNCTION THAT IS USED FOR DRAW HORIZENTAL LINE USING
CHARACTER
===============================================================
===========
*/
void lineHor(int column1, int column2, int row)
{
char c = 205;
for ( column1=column1;column1<=column2; column1++ )
{
gotoxy(column1,row) ;
cprintf("%c",c);
}
}
/
*==============================================================
==========
==
FUNCTION THAT IS USED FOR DRAW VERTICAL LINE USING
CHARACTER
===============================================================
===========
*/
void lineVer(int row1, int row2, int column)
{
char c = 186;
for ( row1=row1; row1<=row2; row1++ )
{
gotoxy(column,row1) ;
printf("%c",c) ;
}
}
/
*==============================================================
==========
===
FUNCTION THAT IS USED FOR DRAW A BOX USING (HORIZENTAL
LINES AND VERTICAL LINES) FUNCTIONS
===============================================================
===========
=*/
void box(int column1, int row1, int column2, int row2)
{
/
*==============================================================
=========
FUNCTION USED FOR OPEN A NEW ACCOUNT IN INITIAL.REC FILE
===============================================================
==========*/
void newAccount(void)
{
char numstr[20];
char ch ;
int i, valid ;
struct date d; //builten structure for date
clrscr();
ini[0].accno = lastAccno()+1;
acc[0].accno = ini[0].accno;
box(1,2,80,24); //draw a box
lineHor(2,79,4); //draw a line
lineHor(2,79,22); //draw a line
gotoxy(70,1);
printf("<0> = EXIT");
textbackground(WHITE);
gotoxy(3,3) ;
for (i=1; i<=76; i++)
printf(" ") ;
textbackground(BLACK);textcolor(BLUE+BLINK);
textbackground(WHITE);
gotoxy(32,3) ;
printf("OPEN NEW ACCOUNT");
textcolor(LIGHTGRAY); textbackground(BLACK); //return in default color
getdate(&d);
acc[0].dd = d.da_day; //save date in structure
acc[0].mm = d.da_mon;
acc[0].yy = d.da_year;
gotoxy(5,5);
printf("Date : %d / %d / %d",acc[0].dd,acc[0].mm,acc[0].yy);
gotoxy(5,7);
printf("ACCOUNT NO # %d",acc[0].accno);
gotoxy(5,9);
printf("NAME : ");
gotoxy(5,11);
printf("FATHER'S NAME : ");
gotoxy(5,13);
printf("ADDRESS : ");
gotoxy(5,15);
printf("INITIAL DEPOSITE :");
fptr = fopen("initial.rec","a");
fclose(fptr);
}
/
*==============================================================
==========
===
FUCTION THAT IS USED FOR ADD NEW DATA IN ACCOUNT .REC FILE
===============================================================
===========
==*/
void addToFileA(void)
{
FILE *fptr;
fptr = fopen("account.rec","a");
fclose(fptr);
}
/
*==============================================================
==========
====
FUNCTION USED FOR TRANSACTION IN ACCOUNT
===============================================================
===========
==*/
void transaction(void)
{
int accno;
int d,m,y;
int i ,valid;
char strnum[10];
char name[25];
char fName[25];
char address[60];
double balance,amt,amount,interest;
char tran;
char type[10];
char tm[20];
char ch;
struct date d1;
clrscr();
box(20,7,50,12);
gotoxy(43,6);
printf("<0> = EXIT");
textcolor(BLUE+BLINK) ; textbackground(WHITE) ;
gotoxy(26,8) ;
cprintf(" ENTER ACCOUNT NO ") ;
textcolor(LIGHTGRAY) ; textbackground(BLACK) ;
gotoxy(22,10);
printf("ACC N0 : ");
gets(strnum);
accno=atoi(strnum);
if(accno == 0)
return;
if(foundAccount(accno) == 0)
{
gotoxy(22,14);
cprintf("7ACCOUNT NO IS NOT FOUND");
getch();
return;
}
clrscr();
box(1,2,80,24);
lineHor(2,79,4);
lineHor(2,79,22);
gotoxy(70,1);
printf("<0> = EXIT");
textbackground(WHITE) ;
gotoxy(3,3) ;
for (i=1; i<=76; i++) cprintf(" ") ;
textbackground(BLACK) ;
textcolor(BLUE+BLINK) ; textbackground(WHITE) ; //return to default color
gotoxy(30,3) ;
cprintf("TRANSACTION IN ACCOUNT") ;
textcolor(LIGHTGRAY) ; textbackground(BLACK) ; //return to default color
getdate(&d1);
d = d1.da_day;
m = d1.da_mon;
y = d1.da_year;
gotoxy(5,5);
printf("Date : %d / %d / %d",d,m,y);
gotoxy(5,7);
printf("Account No # %d",accno);
box(25,9,55,13);
strcpy(name,returnName(accno));
strcpy(fName,returnFname(accno));
strcpy(address,returnAddress(accno));
balance = giveBalance(accno);
gotoxy(27,10);
printf("Name : %s",name);
gotoxy(27,11);
printf("Father Name : %s",fName);
gotoxy(27,12);
printf("Address : %s",address);
gotoxy(5,15);
printf("Last Balance : Rs. %.2lf",balance);
do
{
clear(5,17) ;
valid = 1 ;
clear(5,23) ;
gotoxy(5,23) ;
cprintf("Do You Want to Deposit Or Withdraw ") ;
gotoxy(5,17) ;
printf("Deposit or Withdraw (D/W) : ") ;
tran = getche() ;
if (tran == '0')
return ;
tran = toupper(tran) ; //convert character into upper case
} while (tran != 'D' && tran != 'W') ;
do
{
clear(5,19) ;
clear(5,23) ;
gotoxy(5,23) ;
printf("ENTER TRANSACTION BY CASH OR CHEQUE" );
valid = 1 ;
gotoxy(5,19) ;
printf("(Cash/Cheque) : " );
gets(type) ;
strupr(type) ; //covert string into upper case
if (type[0] == '0')
return ;
if (strcmp(type,"CASH") && strcmp(type,"CHEQUE")) //copare string
{
valid = 0 ;
gotoxy(5,23) ;
cprintf("7ENTER CORRECTLY ") ;
getch() ;
}
} while (!valid) ;
do
{
clear(5,21) ;
clear(5,23) ;
gotoxy(5,23) ;
printf("ENTER AMOUNT FOR TRANSACTION" );
valid = 1 ;
gotoxy(5,21) ;
printf("Amount : Rs." );
gets(tm) ;
amt = atof(tm) ;
amount = amt ;
if (tm[0] == '0')
return ;
if ((tran == 'W' && amount > balance) || (amount < 1))
{
valid = 0 ;
gotoxy(5,23) ;
cprintf("7INVALID DATA ENTERED ") ;
getch() ;
}
} while (!valid) ;
clear(5,23) ;
do
{
clear(40,20) ;
valid = 1 ;
gotoxy(40,20) ;
printf("Save transaction (y/n): ") ;
ch = getche() ;
if (ch == '0')
return ;
ch = toupper(ch) ;
} while (ch != 'N' && ch != 'Y') ;
interest = calculateInterest(accno,balance) ;
if (tran == 'D')
balance = balance + amount + interest ;
else
balance = (balance - amount) + interest ;
updateBalance(accno,balance) ;
acc[0].accno = accno;
acc[0].dd = d;
acc[0].mm = m;
acc[0].yy = y;
acc[0].balance = balance;
strcpy(acc[0].type , type);
acc[0].tran = tran;
acc[0].interest = interest;//interest, amount, balance ;
acc[0].amount = amount;
addToFileA();
getch();
}
/
*==============================================================
==========
==
FUNCTION THAT IS RETURN NAME OF PERSON FROM INITIAL.REC FILE
===============================================================
===========
=*/
char *returnName(int a_no)
{
FILE *fptr;
long int offset;
char name[30];
strcpy(name, ini[a_no].name);
}
return name;
}
/
*==============================================================
==========
==
FUNCTION THAT IS RETURN FATHER NAME OF PERSON FROM
INITIAL.REC FILE
===============================================================
===========
=*/
char *returnFname(int a_no)
{
FILE *fptr;
long int offset;
char fName[25];
strcpy(fName, ini[a_no].fName);
}
return fName;
}
/
*==============================================================
==========
=
FUNCTION THAT IS RETURN ADDRESS OF A PERSON FROM INITIAL.REC
FILE
/
*==============================================================
==========
*/
char *returnAddress(int a_no)
{
FILE *fptr;
long int offset;
char address[30];
strcpy(address, ini[a_no].address);
}
return address;
}
/
*==============================================================
==========
THIS FUNCTION ADD DEPOSIT IN BALANCE
===============================================================
=========*/
double giveBalance(int a_no)
{
FILE *fptr;
long int offset;
long balance;
balance = ini[a_no].balance;
}
return balance;
}
/
*==============================================================
==========
==
FUNCTION USED FOR CALCULATE INTEREST
===============================================================
===========
=*/
double calculateInterest(int accno, double balance)
{
FILE *fptr;
int d1,m1,y1;
int d2, m2, y2 ;
struct date d;
double interest=0 ;
int days,months=0 ;
int count = 0;
if(accno == acc[count].accno)
{
d1 = acc[count].dd;
m1 = acc[count].mm;
y1 = acc[count].yy;
break;
}
count++;
}
getdate(&d);
d2 = d.da_day ;
m2 = d.da_mon ;
y2 = d.da_year ;
}
/
*==============================================================
==========
===
FUNCTION USED FOR COUNTING NUMBER OF DAYS
===============================================================
===========
=*/
int noOfDays(int d1, int m1, int y1, int d2, int m2, int y2)
{
static int month[] = {31,28,31,30,31,30,31,31,30,31,30,31} ;
int days = 0 ;
while (d1 != d2 || m1 != m2 || y1 != y2)
{
days++ ;
d1++ ;
if (d1 > month[m1-1])
{
d1 = 1 ;
m1++ ;
}
if (m1 > 12)
{
m1 = 1 ;
y1++ ;
}
}
return days ;
}
/
*==============================================================
==========
=
FUNCTION THAT IS RETURN UPDATE BALANCE FROM INITIAL.REC FILE
===============================================================
==========*/
void updateBalance(int a_no,double bal)
{
FILE *fptr;
long int offset;
int acc = a_no -1;
fptr = fopen("initial.rec","r+");
ini[acc].balance = bal;
fclose(fptr);
}
/
*==============================================================
==========
====
FUNCTION THAT IS USED FOR CHECK A RECORD FROM INITIAL.REC
===============================================================
===========
==*/
int foundAccount(int ac)
{
int found = 0;
FILE *fptr;
int count = 0;
if(ac == ini[count].accno)
{
found = 1;
break;
}
count++;
}
fclose(fptr);
return found;
/
*==============================================================
==========
THIS FUNCTION RETURN A COMPLETE RECORD FROM INITIAL.REC FILE
===============================================================
=========*/
void display(void)
{
int d1,m,y,n = 0;
int accno;
int row = 8, flag = 0 ;
char numstr[10];
char name[25];
char fName[25];
char address[60];
FILE *fptr;
struct date d;
clrscr();
box(20,7,50,12);
gotoxy(43,6);
printf("<0> = EXIT");
textcolor(BLUE+BLINK) ; textbackground(WHITE) ;
gotoxy(26,8) ;
cprintf(" ENTER ACCOUNT NO ") ;
textcolor(LIGHTGRAY) ; textbackground(BLACK) ;
gotoxy(22,10);
printf("ACC N0 : ");
gets(numstr);
accno=atoi(numstr);
if(accno == 0)
return;
if(foundAccount(accno) == 0)
{
gotoxy(22,14);
cprintf("7ACCOUNT NO IS NOT FOUND");
getch();
return;
clrscr();
box(1,1,80,24);
lineHor(2,79,22);
getdate(&d);
d1 = d.da_day;
m = d.da_mon;
y = d.da_year;
strcpy(name, returnName(accno));
strcpy(fName, returnFname(accno));
strcpy(address, returnAddress(accno));
gotoxy(64,3);
printf("DATE : %d/%d/%d",d1,m,y);
textcolor(WHITE) ;
gotoxy(2,3) ;
printf("ACCOUNT NO # %d",accno) ;
gotoxy(30,2);
printf("NAME : %s",name);
gotoxy(30,3);
printf("FATHER NAME: %s",fName);
gotoxy(30,4);
printf("ADDRESS : %s",address);
lineHor(2,79,5);
textbackground(WHITE) ;
gotoxy(2,4) ;
textcolor(BLUE);
gotoxy(3,6);
printf(" DATE PARTICULAR DEPOSIT WITDRAW INTEREST
BALANCE ");
textcolor(LIGHTGRAY) ; textbackground(BLACK) ;
lineHor(2,79,7);
fptr = fopen("account.rec","r");
while( fread(&acc[n], sizeof(acc[n]), 1, fptr) ==1)
{
if (accno == acc[n].accno)
{
flag = 0 ;
delay(10) ;
gotoxy(3,row) ;
printf("%d/%d/%d",acc[n].dd,acc[n].mm,acc[n].yy) ;
gotoxy(16,row) ;
printf("%s",acc[n].type) ;
if (acc[n].tran == 'D')
gotoxy(30,row) ;
else
gotoxy(43,row) ;
printf("%.2lf",acc[n].amount);
gotoxy(57,row) ;
printf("%.2lf",acc[n].interest) ;
gotoxy(71,row) ;
printf("%.2lf",acc[n].balance) ;
row++ ;
if (row == 22)
{
flag = 1 ;
row = 8 ;
gotoxy(4,23) ;
printf("press a key to continue..." );
getch() ;
clrscr() ;
box(1,1,80,24); lineHor(2,79,22);
textcolor(WHITE) ;
gotoxy(2,3) ;
cprintf("ACCOUNT NO # %d",accno) ;
gotoxy(30,2);
cprintf("NAME : %s",name);
gotoxy(30,3);
cprintf("FATHER NAME: %s",fName);
gotoxy(30,4);
cprintf("ADDRESS : %s",address);
lineHor(2,79,5);
textbackground(WHITE) ;
gotoxy(2,4) ;
textcolor(BLUE);
gotoxy(3,6);
cprintf(" DATE PARTICULAR DEPOSIT WITDRAW INTEREST
BALANCE ");
textcolor(LIGHTGRAY) ; textbackground(BLACK) ;
lineHor(2,79,7);
}
}
n++;
}
fclose(fptr) ;
if (!flag)
{
gotoxy(4,23) ;
printf("press a key to continue...") ;
getch() ;
}
}
/
*==============================================================
==========
===
FUNCTION THAT IS DISPLAY ALL RECORD FROM INITIAL.REC FILE
===============================================================
===========
==*/
void displayList(void)
{
FILE *fptr;
int n = 0,i;
struct date d;
int d1,m,y;
box(1,1,80,24);
lineHor(2,79,22);
lineHor(2,79,3);
getdate(&d);
d1 = d.da_day;
m = d.da_mon;
y = d.da_year;
gotoxy(60,2);
printf("DATE : %d/%d/%d",d1,m,y);
textcolor(BLUE+BLINK) ; textbackground(WHITE) ;
gotoxy(25,2) ;
cprintf(" LIST OF ACCOUNT ") ;
textbackground(WHITE) ;
gotoxy(2,4) ;
for (i=1; i<=78; i++) cprintf(" ") ;
textcolor(BLUE);
gotoxy(3,4);
cprintf("ACC NO NAME FATHER NAME
BALANCE");
textcolor(LIGHTGRAY) ; textbackground(BLACK) ;
lineHor(2,79,5);
if ( (fptr = fopen("initial.rec","r"))== NULL)
printf("File is Empty.......
");
else
{
case '1':
modify();
break;
case '2':
{
Delete();
break;
}
}
}
/
*==============================================================
==========
======
FUNCTION THAT IS USED FOR MODIFIED A RECORD FROM INITIAL.REC
FILE
===============================================================
===========
=====*/
void modify(void)
{
int acc ;
FILE *fptr;
long int offset;
int i;
int accno,rec;
char ch;
int modified=0, valid=0 ;
char strnum[20];
struct date d1;
getdate(&d1);
clrscr();
box(20,7,50,12);
gotoxy(43,6);
printf("<0> = EXIT");
textcolor(BLUE+BLINK) ; textbackground(WHITE) ;
gotoxy(26,8) ;
cprintf(" ENTER ACCOUNT NO ") ;
textcolor(LIGHTGRAY) ; textbackground(BLACK) ;
gotoxy(22,10);
printf("ACC N0 : ");
gets(strnum);
accno = atoi(strnum);
if(accno == 0)
return;
if(foundAccount(accno) == 0)
{
gotoxy(22,14);
cprintf("7ACCOUNT NO IS NOT FOUND");
getch();
return;
}
clrscr();
strcpy(ini[0].name,returnName(accno));
strcpy(ini[0].fName, returnFname(accno));
strcpy(ini[0].address, returnAddress(accno));
box(1,2,80,24);
lineHor(2,79,4);
lineHor(2,79,22);
gotoxy(1,1) ;
printf("PRESS (0) TO EXIT") ;
textbackground(WHITE) ;
gotoxy(3,3) ;
for (i=1; i<=76; i++) cprintf(" ") ;
textbackground(BLACK) ;
textcolor(BLACK+BLINK) ; textbackground(WHITE) ;
gotoxy(30,3) ;
cprintf("MODIFY ACCOUNT SCREEN") ;
textcolor(LIGHTGRAY) ; textbackground(BLACK) ;
gotoxy(3,6);
printf("ACCOUNT NO.# %d",accno);
gotoxy(63,6);
printf("DATE : %d/%d/%d",d1.da_day,d1.da_mon,d1.da_year);
box(20,7,60,12);
gotoxy(23,8);
printf("NAME : %s",ini[0].name);
gotoxy(23,9);
printf("FATHER NAME: %s",ini[0].fName);
gotoxy(23,10);
printf("ADDRESS : %s",ini[0].address);
do
{
clear(5,13) ;
gotoxy(5,13) ;
printf("Modify this account (y/n): ");
ch = getche() ;
if (ch == '0')
return ;
ch = toupper(ch) ;
} while (ch != 'N' && ch != 'Y') ;
if (ch == 'N')
return ;
clear(5,13) ;
gotoxy(5,15) ;
printf("Name : " );
gotoxy(5,17) ;
printf("Father Name : " );
gotoxy(5,19) ;
printf("Address : " );
do
{
clear(19,15) ;
clear(5,23) ;
gotoxy(5,23) ;
printf("ENTER NAME or PRESS <ENTER> FOR NO CHANGE");
valid = 1 ;
gotoxy(21,15) ;
gets(ini[0].name) ;
strupr(ini[0].name) ;
if (ini[0].name[0] == '0')
return ;
if (strlen(ini[0].name) > 25 )
{
valid = 0 ;
gotoxy(5,23) ;
cprintf("7NAME SHOULD NOT BE GREATER THAN 25") ;
getch() ;
}
} while (!valid) ;
if (strlen(ini[0].name) > 0)
modified = 1 ;
else
strcpy(ini[0].name,returnName(accno) );
do
{
clear(19,17) ;
clear(5,23) ;
gotoxy(5,23) ;
printf("ENTER NAME or PRESS <ENTER> FOR NO CHANGE");
valid = 1 ;
gotoxy(21,17) ;
gets(ini[0].fName) ;
strupr(ini[0].fName) ;
if (ini[0].fName[0]=='0')
return;
if (strlen(ini[0].fName) > 25)
{
valid = 0 ;
gotoxy(5,23) ;
cprintf("7NAME SHOULD NOT BE GREATER THAN 25") ;
getch() ;
}
} while (!valid) ;
if (strlen(ini[0].fName) > 0)
modified = 1 ;
else
strcpy(ini[0].fName,returnFname(accno));
do
{
clear(19,19) ;
clear(5,23) ;
gotoxy(5,23) ;
printf("ENTER ADDRESS or PRESS <ENTER> FOR NO CHANGE");
valid = 1;
gotoxy(21,19) ;
gets(ini[0].address) ;
strupr(ini[0].address) ;
if (ini[0].address[0] == '0')
return ;
if (strlen(ini[0].address) > 25)
{
valid = 0 ;
gotoxy(5,23) ;
cprintf("7SHOULD NOT BE BLANK OR GREATER THAN 55") ;
getch() ;
}
} while (!valid) ;
if (strlen(ini[0].address) > 0)
modified = 1 ;
else
strcpy(ini[0].address,returnAddress(accno) );
if (!modified)
return ;
clear(5,23) ;
do
{
clear(5,18) ;
gotoxy(35,19) ;
printf("Do you want to save changes (y/n): ") ;
ch = getche() ;
if (ch == '0')
return ;
ch = toupper(ch) ;
} while (ch != 'N' && ch != 'Y') ;
if (ch == 'N')
return ;
//==============================================================
//==============================================================
fptr = fopen("initial.rec","r+");
ini[acc].accno = accno;
strcpy(ini[acc].name, ini[0].name);
strcpy(ini[acc].fName, ini[0].fName);
strcpy(ini[acc].address, ini[0].address);
ini[acc].balance = giveBalance(accno);
fclose(fptr);
gotoxy(5,21) ;
printf("7Record Modified");
gotoxy(5,23) ;
printf("press a key to continue..." );
getch();
}
/
*==============================================================
==========
===
FUNCTION THAT IS USED DELETION RECORD FROM BOTH FILES
USING DELETEACCOUNT() AND DELETE_ACCOUNT() FUNCTIONS
===============================================================
===========
=*/
void Delete(void)
{
int accno,i;
char strnum[10],ch;
}
/
*==============================================================
=========
FUNCTION THAT IS DELETE A RECORD FROM INITIAL.REC FILE
===============================================================
=========*/
void deleteAccount(int acc_no)
{
FILE *fptr;
FILE *tptr;
int n=0;
fptr = fopen("initial.rec","r");//open the orginal file
tptr = fopen("temp.rec","w");//opening a temparay file
}
/
*==============================================================
==========
===
FUNCTION THAT IS DELETE A RECORD FROM ACCOUNT.REC FILE
===============================================================
===========
==*/
void delete_account(int acc_no)
{
FILE *fptr;
FILE *tptr;
int n=0;
/
*==============================================================
==========
===
FUNCTION THAT IS RETURN TOTAL NUMBER OF RECORD IN INITIAL.REC
FILE
===============================================================
===========
==*/
int recordno(int a_no)
{
FILE *fptr;
int count = 0;
if(a_no == ini[count].accno)
break;
count++;
}
fclose(fptr);
return count;
}
}
/
*==============================================================
==========
==
HELP OF PRGRAM
===============================================================
===========
*/
void help(void)
{
clrscr();
textmode(BW80);
box(2,2,79,25);
gotoxy(27,3); cprintf("*WELCOME TO PROJECT BANKING*") ;
gotoxy(6,5); printf("IN THIS PROJECT YOU CAN KEEP RECORD FOR DAILY
BANKING TRANSACTIONS.");
gotoxy(11,7); printf(" THIS PROGRAM IS CAPABLE OF HOLDING ANY No. OF
ACCOUNTS.");
gotoxy(3,9); printf("1) THE FIRST OPTION YOU CAN OPEN A NEW ACCOUNT
OF A
PARTICULAR PERSON.");
gotoxy(3,11); printf("(NOTE:OPENING AMOUNT i.e.THE FIRST DEPOSIT
SHOULD
NOT BE LESS THAN RS.500.");
gotoxy(3,13); printf("2) SECOND OPTION IS DISPLAYED BY GIVING SIMPLY
THE
ACCOUNT NO.THAT PERSON.");
gotoxy(3,15); printf("3) IN THIRD OPTION YOU CAN SEE THE LIST OF
ACCOUNTS.");
gotoxy(3,17); printf("4) THROUGH FOURTH OPTION YOU CAN DO BANKING
TRANSACTIONS (DEPOSIT/WITHDRAW).");
gotoxy(3,19); printf("5) IN FIFTH OPTION YOU CAN CLOSE OR MODIFY
ACCOUNT
OF A PERSON." );
gotoxy(3,21); printf("6) IN SIX OPTION THE HELP MENU IS DISPLAYED.");
gotoxy(3,23); printf("7) In SEVENTH OPTION YOU EXIT FROM PROJECT.");
textcolor(RED+BLINK) ; textbackground(WHITE+BLINK) ;
gotoxy(26,25) ; cprintf(" Press a key to continue ") ;
textcolor(LIGHTGRAY) ; textbackground(BLACK) ;
gotoxy(25,2) ;
getch();
}
/
*==============================================================
==========
==
HEART OF PROGRAM MAIN FUNCTION
===============================================================
===========
=*/
void main(void)
{
gra2();
mainMune();
}
/
*==============================================================
==========
=
FUNCTION THAT IS USED FOR MAIN MANU
===============================================================
==========*
/
void mainMune(void)
{
char ch;
int a;
textmode(BW40);
textbackground(5) ;
for (a=1; a<=11700; a++) cprintf(" ") ;
clrscr();
textbackground(1) ;
for (a=1; a<=11700; a++) cprintf(" ") ;
textcolor(RED) ;
box(2,2,38,4);
textcolor(YELLOW) ;
gotoxy(4,3);
cprintf("P R O J E C T O F B A N K I N G");
for(a=2;a<39;a++)
{
lineHor(2,a,5);
if( (39-a)>1)
lineHor(39-a,38,1);
delay(30);
}
do
{
clrscr();
manu();
MAIN:
textcolor(7);
gotoxy(30,21);
ch=getch();
switch(ch)
{
case '1':
{clrscr();
textmode(BW80);
newAccount();
gotoxy(53,45);}
break;
case '2':
{clrscr();
textmode(BW80);
display();
getch();
}break;
case '3':
{ clrscr();
textmode(BW80);
displayList();
getch();
gotoxy(53,45);
cprintf("PRESS ANY KEY TO CONTINUE...");
}break;
case '4':
{ clrscr();
textmode(BW80);
transaction();
}break;
case '5':{
textmode(BW80);
editAccount();}break;
case '6':
textmode(BW80);
help();
break;
case '7': {
clrscr();
textmode(4);
gotoxy(13,13);
printf("GOD BLESS YOU");
gotoxy(80,25);
getch();
exit(0); }break;
default:goto MAIN;
}
}while(1);
}
/
*==============================================================
==========
===
FUNCTION THAT IS USED FOR REPRESENTING MANU
===============================================================
===========
=*/
void manu(void)
{
int a;
textmode(BW40);
textbackground(1) ;
for (a=1; a<=11700; a++) cprintf(" ") ;
textcolor(RED) ;
box(2,2,38,4);
textcolor(YELLOW) ;
gotoxy(4,3);
cprintf("P R O J E C T O F B A N K I N G");
lineHor(1,39,5);
box(1,1,39,25);
textcolor(RED);
gotoxy(4,9);cprintf("O");
gotoxy(36,9);cprintf("O");
gotoxy(4,11);cprintf("P");
gotoxy(36,11);cprintf("P");
gotoxy(4,13);cprintf("T");
gotoxy(36,13);cprintf("T");
gotoxy(4,15);cprintf("I");
gotoxy(36,15);cprintf("I");
gotoxy(4,17);cprintf("O");
gotoxy(36,17);cprintf("O");
gotoxy(4,19);cprintf("N");
gotoxy(36,19);cprintf("N");
gotoxy(4,21);cprintf("S");
gotoxy(36,21);cprintf("S");
textcolor(YELLOW);
box(7,7,32,23);
textcolor(4) ; textbackground(15) ;
gotoxy(9,9);
cprintf(" 1 - NEW ACCOUNT ");
gotoxy(9,11);
cprintf(" 2 - SEE A ACCOUNT ");
gotoxy(9,13);
cprintf(" 3 - LIST OF ACCOUNT ");
gotoxy(9,15);
cprintf(" 4 - TRANSACTIONS ");
gotoxy(9,17);
cprintf(" 5 - EDIT ACCOUNT ");
gotoxy(9,19);
cprintf(" 6 - HELP ");
gotoxy(9,21);
cprintf(" 7 - QUIT ");
}
/
*==============================================================
==========
===
FUNCTION THAT IS USED FOR DRAWING FOR FRONT PAGE
===============================================================
===========
=*/
void gra2()
{
int gd=DETECT,gm;
int stangle,col=0;
clrscr(); //To make a designer ellipse
initgraph(&gd, &gm, "c:\tc\bgi");
setcolor(8);
ellipse(320,240,0,360,300,150);
settextstyle(1,0,2);
settextjustify(1,1);
setcolor(5);
outtextxy(320,112,"PROJECT OF BANKING");
delay(250);
settextstyle(1,0,2);
setcolor(20);
outtextxy(320,152,"Presented By:");
delay(250);
outtextxy(320,325,"BS(CS) 2ND SEMESTER");
settextstyle(1,0,2);
setcolor(3);
delay(250);
outtextxy(320,205,"MUHAMMAD AKRAM BALOCH ");
for (stangle=0;!kbhit();stangle++)
{
setcolor(col);
ellipse(320,240,stangle,stangle+20,300,150);
ellipse(320,240,stangle+180,stangle+200,300,150);
delay(9);
setcolor(8);
ellipse(320,240,stangle-1,stangle+19,300,150);
ellipse(320,240,stangle-1+180,stangle+199,300,150);
col++;
}
closegraph();
}
/
*==============================================================
==========
==
THE END
===============================================================
===========
==*/
/* WARNING: be sure to edit the line 23 and make "text the file you
want to copy, be sure to leave the file name in quotes, filename can me
relative or absolute
*/
#include <stdio.h>
int main()
{
char c[100];
FILE *inFile;
FILE *outFile;
char sourceFile;
char destFile;
int Byte;
int i;
if(inFile==NULL)
{
/*if pointer to inFile is a null pointer,
return an error and display msg */
/*
Student Record System - C implementation
*/
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<dos.h>
#include<stdlib.h>
#include<ctype.h>
FILE *fp;
struct student{
char snum[13];
char fname[20];
char sname[20];
char mi;
char ccode;
}record;
void Temp1(void);
void twolinebox(int x1,int y1,int x2,int y2){
int x,y;
gotoxy(x1,y1); printf("É"); //alt-201
gotoxy(x2,y1); printf("»"); //alt-187
for(y=y1+1;y<y2;y++){
gotoxy(x1,y); printf("º"); //alt-186
gotoxy(x2,y); printf("º"); //alt-186
}
gotoxy(x1,y2); printf("È"); //alt-200
gotoxy(x2,y2); printf("¼"); //alt-188
for(x=x1+1;x<x2;x++){
gotoxy(x,y1); printf("Í"); //alt-205
gotoxy(x,y2); printf("Í"); //alt-205
}
gotoxy(x1+1,y1+1);
}
void Create(void){
char opt;
center(21,"WARNING!!!");
center(22,"You are about to create a new file");
center(23,"This will erase all records in the file...");
center(24,"Are you sure you want to proceed?[Y/N] ");
opt=getche(); opt=toupper(opt);
if(opt=='Y'){
fp=fopen("Group4.txt","w");
center(24," ");
center(24,"File successfully created!");
}
getch();
fclose(fp);
}
void Add(void){
char opt;
fp=fopen("Group4.txt","a");
clrscr();
Temp1();
gotoxy(19,8); scanf(" "); gets(record.snum);
gotoxy(19,10); scanf(" "); gets(record.fname);
gotoxy(19,12); scanf(" "); gets(record.sname);
gotoxy(19,14); record.mi=getche(); record.mi=toupper(record.mi);
gotoxy(19,16); record.ccode=getche();
record.ccode=toupper(record.ccode);
gotoxy(5,22); clreol(); printxy(79,22,"º");
fprintf(fp,"%s %s %s %c
%c",record.snum,record.fname,record.sname,record.mi,record.ccode);
gotoxy(5,21); clreol(); center(21,"Record successfully added!");
printxy(79,21,"º"); gotoxy(53,22); delay(1000);
center(22,"Press any key to go to main menu..."); getch();
fclose(fp);
}
void Temp1(void){
twolinebox(2,6,79,20);
twolinebox(2,20,79,24);
twolinebox(2,2,79,24);
center(4,"ADD RECORD");
printxy(6,8,"Student no: ");
printxy(6,10,"First Name: ");
printxy(6,12,"Last Name: ");
printxy(6,14,"Middle init:");
printxy(6,16,"Course code: ");
center(22,"Course code: [A]-CompSci, [B]-for InfoTech, [any
key]-Sevices");
gotoxy(19,7);
}
void List(void){
int count=0,i,x=0,page=1,CS=0,IT=0,Serv=0;
fp=fopen("Group4.txt","r");
clrscr();
center(2,"Polytechnic University of the Philippines");
center(3,"Sta. Mesa, Manila");
center(5,"College of Computer Management and Information Technology");
printxy(10,7,"Record Student # Name
Course");
for(i=1;i<80;i++){ gotoxy(i,8); puts("Í"); /*Alt-205*/ }
while(fscanf(fp,"%s %s %s %c
%c",&record.snum,&record.fname,&record.sname,&record.mi,&record.ccode)!=EO
F){
if(count!=0&&count%5==0){ printxy(5,23,"Press any key to
continue..."); getch(); x=0;
for(i=10;i<=24;i++){gotoxy(1,i); clreol();}
page++;
}
gotoxy(70,4); printf("Page %d",page);
gotoxy(13,10+x); printf("%d",count+1);
gotoxy(19,10+x); printf("%s",record.snum);
gotoxy(37,10+x); printf("%s, %s
%c.",record.sname,record.fname,record.mi);
gotoxy(62,10+x);
switch(record.ccode){
case 'A': printf("CompSci"); CS++; break;
case 'B': printf("InfoTech"); IT++; break;
default : printf("Services"); Serv++; break;
}
x++;
count++;
}
printxy(25,17,"TOTAL");
gotoxy(15,18); printf("Comp Sci: %d",CS);
gotoxy(15,19); printf("InfoTech: %d",IT);
gotoxy(15,20); printf("Services: %d",Serv);
printxy(5,23,"Press any key to go to main menu...");
getch();
fclose(fp);
}
void Quit(void){
clrscr();
twolinebox(2,2,79,24);
center(8,"PROGRAMMED");
center(9,"BY");
center(11,"Group 4");
center(13,"Badion, Frederick A.");
center(14,"Sañosa, Emmanuel R.");
center(15,"Zamora, Sweet Joan J.");
delay(5000);
exit(1);
fclose(fp);
}
void Err_mess(void){
sound(1000);
center(22,"Invalid Input!");
delay(1000);
nosound();
}
void main(){
char choice;
do{
clrscr();
twolinebox(29,6,51,8);
twolinebox(20,5,60,18);
twolinebox(2,20,79,25);
twolinebox(2,2,79,25);
center(7,"MAIN MENU");
printxy(30,9,"Press:");
printxy(30,11,"[A]-Create File");
printxy(30,12,"[B]-Add Record");
printxy(30,13,"[C]-List Record");
printxy(30,14,"[D]-Quit Program");
printxy(30,16,"Enter your choice..."); gotoxy(50,16);
choice=getch(); choice=toupper(choice);
switch(choice){
case 'A': Create(); break;
case 'B': Add(); break;
case 'C': List(); break;
case 'D': Quit(); break;
default: Err_mess(); break;
}
}while(choice!='D');
}
Tower of Hanoi
#include<stdio.h>
void initialize (int disks, int peg_A[8], int peg_B[8], int peg_C[8]);
void get_number_of_disks(int *disks);
void print_status(int disks, int peg_A[8], int peg_B[8], int peg_C[8]);
void print_no_disk(char *choice_from);
int validate_move_from(char *choice_from, int peg_A[8], int peg_B[8],
int
peg_C[8]);
int validate_move_to(int disks, char choice_from, char *choice_to, int
*index_from, int peg_A[8], int peg_B[8], int peg_C[8]);
void disk_on_top(int disks, int *top_of_stack_to, char choice_to, int
peg_A[8],
int peg_B[8], int peg_C[8]);
void move_disk(int disks, char choice_from, char choice_to, int
index_from, int peg_A[8], int peg_B[8], int peg_C[8]);
printf("
Instructions on playing TOWERS OF HANOI:
There are
three pegs, labeled A, B, and C.
The
only
limitation is that you may not place a disk on top of one which is
smaller.
");
get_number_of_disks(&disks);
initialize(disks, peg_A, peg_B, peg_C);
print_status(disks, peg_A, peg_B, peg_C);
while (peg_C[disks-1]!=3)
{ validate_move_from(&choice_from, peg_A, peg_B, peg_C);
if(choice_from=='Q' || choice_from=='q')
break;
validate_move_to(disks, choice_from, &choice_to,
&index_from, peg_A, peg_B, peg_C);
if(choice_to=='Q' || choice_to=='q')
break;
move_disk(disks, choice_from, choice_to, index_from,
peg_A, peg_B, peg_C);
print_status(disks, peg_A, peg_B, peg_C); }
if(peg_C[disks-1]==3)
printf("Congratulations! You won…
");
return 0; }
"); }
/*prints that there's no disk and asks the user to enter another
input*/
void print_no_disk(char *choice_from)
{ printf("There's no disk!
Choose a peg with disk(s).
Move a
disk
from what peg?: ");
scanf("%s", choice_from); }
/*asks the user to enter the name of the peg from where a disk will be
removed*/
/*validates input*/
int validate_move_from(char *choice_from, int peg_A[8], int peg_B[8],
int
peg_C[8])
{ printf("Move a disk FROM what peg?: ");
scanf("%c", choice_from);
if (*choice_from=='Q' || *choice_from=='q')
return 0;
while(peg_A[0] == 1 && (*choice_from == 'A' || *choice_from
=='a'))
print_no_disk(choice_from);
while(peg_B[0] == 1 && (*choice_from == 'B' || *choice_from
=='b'))
print_no_disk(choice_from);
while(peg_C[0] == 1 && (*choice_from == 'C' || *choice_from
=='c'))
print_no_disk(choice_from);
while(*choice_from<'A' || (*choice_from>'C' &&
*choice_from<'a')
|| *choice_from>'c')
{printf("(A, B, C or Q only): ");
scanf("%c", choice_from);
if (*choice_from=='Q' || *choice_from=='q')
return 0;
while(peg_A[0] == 1 && (*choice_from == 'A' ||
*choice_from =='a'))
print_no_disk(choice_from);
while(peg_B[0] == 1 && (*choice_from == 'B' ||
*choice_from =='b'))
print_no_disk(choice_from);
while(peg_C[0] == 1 && (*choice_from == 'C' ||
*choice_from =='c'))
print_no_disk(choice_from); }
return 0;}
/*asks the user to enter the name of the peg to which a disk will be
placed*/
/*also validates input*/
int validate_move_to(int disks, char choice_from, char *choice_to, int
*index_from, int peg_A[8], int peg_B[8], int peg_C[8])
{ int i;
int top_of_stack_from, /*the disk to be removed*/
top_of_stack_to; /*the smallest disk in a certain
peg*/
for (i=disks-1; i>=0; i--)
{ if ((choice_from=='A' || choice_from=='a') &&
peg_A[i]!=1)
{ top_of_stack_from = peg_A[i];
*index_from=i;
break; }
else if ((choice_from=='B' || choice_from=='b') &&
peg_B[i]!=1)
{ top_of_stack_from = peg_B[i];
*index_from=i;
break; }
else if ((choice_from=='C' || choice_from=='c') &&
peg_C[i]!=1)
{ top_of_stack_from = peg_C[i];
*index_from=i;
break; }}
printf("Move the disk TO: ");
scanf("%c", choice_to);
if (*choice_to=='Q' || *choice_to=='q')
return 0;
disk_on_top(disks, &top_of_stack_to, *choice_to, peg_A, peg_B,
peg_C);
while(*choice_to<'A' || (*choice_to>'C' && *choice_to<'a') ||
*choice_to>'c')
{ printf("(A, B, or C only): ");
scanf("%c", choice_to);
if (*choice_to=='Q' || *choice_to=='q')
return 0;
disk_on_top(disks, &top_of_stack_to, *choice_to, peg_A, peg_B,
peg_C); }
while(top_of_stack_to-top_of_stack_from<0)
{ printf("That is an INVALID move!
Choose a peg with a
larger disk.
Move the disk TO: ");
scanf("%c", choice_to);
if (*choice_to=='Q' || *choice_to=='q')
return 0;
while(*choice_to<'A' || (*choice_to>'C' &&
*choice_to<'a')
|| *choice_to>'c')
{ printf("(A, B, or C only): ");
scanf("%c", choice_to);
if (*choice_to=='Q' || *choice_to=='q')
return 0;
disk_on_top(disks, &top_of_stack_to,
*choice_to,
peg_A, peg_B, peg_C); }}
return 0; }
Code :
#include<stdio.h>
main()
{
int i,a[10],n=0;
printf("WELCOME TO THE GAME
""KAUN BANEGA CROREPATHI""
It
contains
10 QUESTIONS each carries 10 LAKHS
");
for(i=1;i<=10;i++)
{
n=n+1;
switch(i)
{
case 1:
printf("In what direction muslim pray
1.East
2.South
3.Nearby
Mosque's direction
4.Mecca's direction
");
scanf("%d",&a[n]);
if(a[n]==4)
{
printf("You have entered the correct answer
/*------------------------------------------------------------------------
-*/
/*------------------------------------------------------------------------
-*/
/*------------------------------------------------------------------------
-*/
/* VIDEO LIBRARY MANAGEMENT SYSTEM */
/*------------------------------------------------------------------------
-*/
/*------------------------------------------------------------------------
-*/
/*------------------------------------------------------------------------
-*/
#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<string.h>
#include<graphics.h>
#define PATH ".\bgi"
#define TBG textbackground(WHITE);textcolor(BLUE)
typedef struct customer
{
long id;
char name[20];
char pn[12];
char address[40];
char category;
int doj[3];
}cust;
void main_menu()
{
char *menu[]={"CUSTOMER SECTION",
"MOVIE SECTION",
"TRANSACTION SECTION",
"EXIT"};
char ch;
int gd=DETECT,gm,i,choice=0;
initgraph(&gd,&gm,PATH);
setfillstyle(SOLID_FILL,RED);
bar(0,0,640,480);
title("MAIN MENU",180);
status();
box(0,menu[0]);
box(1,menu[1]);
box(2,menu[2]);
box(3,menu[3]);
selectbox(choice,menu[choice]);
//72 up
//80 down
//75 left
//77 right
//13 enter
//49 1
//71 Home
//79 End
//73 PgUp
//81 PgDown
//27 Escape
while((ch=getch())!=13)
{
switch(ch)
{
case 80:
case 81:
choice++;
if(choice==4)
choice=0;
selectbox(choice,menu[choice]);
for(i=0;i<=3;i++)
{
if(i==choice) continue;
box(i,menu[i]);
}
break;
case 72:
case 73:
choice--;
if(choice==-1)
choice=3;
selectbox(choice,menu[choice]);
for(i=0;i<=3;i++)
{
if(i==choice) continue;
box(i,menu[i]);
}
}
}
pressbutton(choice,menu[choice]);
switch(choice)
{
case 0:
size=sizeof(ctr);
customer();
break;
case 1:
movie();
break;
case 2:
transactions();
break;
case 3:
closegraph();
restorecrtmode();
exit(0);
}
}
customer()
{
char *menu[]={
"ADD CUSTOMER",
"MODIFY CUSTOMER",
"DELETE CUSTOMER",
"LIST CUSTOMER",
"BACK TO MAIN MENU",
"EXIT"
};
char ch;
int gd=DETECT,gm;
int i,choice=0;
initgraph(&gd,&gm,PATH);
setfillstyle(SOLID_FILL,RED);
bar(0,0,640,480);
title("CUSTOMER MENU",130);
status();
box(0,menu[0]);
box(1,menu[1]);
box(2,menu[2]);
box(3,menu[3]);
box(4,menu[4]);
box(5,menu[5]);
selectbox(choice,menu[choice]);
//72 up
//80 down
//75 left
//77 right
//13 enter
//49 1
//71 Home
//79 End
//73 PgUp
//81 PgDown
//27 Escape
while((ch=getch())!=13)
{
switch(ch)
{
case 80:
case 81:
choice++;
if(choice==6)
choice=0;
selectbox(choice,menu[choice]);
for(i=0;i<=5;i++)
{
if(i==choice) continue;
box(i,menu[i]);
}
break;
case 72:
case 73:
choice--;
if(choice==-1)
choice=5;
selectbox(choice,menu[choice]);
for(i=0;i<=5;i++)
{
if(i==choice) continue;
box(i,menu[i]);
}
}
}
pressbutton(choice,menu[choice]);
closegraph();
restorecrtmode();
clrscr();
if((fc=fopen("c:\customer.txt","rb+"))==NULL)
fc=fopen("c:\customer.txt","wb+");
switch(choice)
{
case 0:
addcus();
break;
case 1:
rewind(fc);
modify();
break;
case 2:
delete();
break;
case 3:
listcust();
break;
case 4:
fclose(fc);
main_menu();
break;
case 5:
fclose(fc);
exit(1);
}
}
movie()
{
char *menu[]={
"ADD MOVIE",
"LIST MOVIES",
"SEARCH MOVIE",
"BACK TO MAIN MENU",
"EXIT"
};
char ch;
int gd=DETECT,gm;
int i,choice=0;
initgraph(&gd,&gm,PATH);
setfillstyle(SOLID_FILL,RED);
bar(0,0,640,480);
title("MOVIE MENU",165);
status();
box(0,menu[0]);
box(1,menu[1]);
box(2,menu[2]);
box(3,menu[3]);
box(4,menu[4]);
selectbox(choice,menu[choice]);
//72 up
//80 down
//75 left
//77 right
//13 enter
//49 1
//71 Home
//79 End
//73 PgUp
//81 PgDown
//27 Escape
while((ch=getch())!=13)
{
switch(ch)
{
case 80:
case 81:
choice++;
if(choice==5)
choice=0;
selectbox(choice,menu[choice]);
for(i=0;i<=4;i++)
{
if(i==choice) continue;
box(i,menu[i]);
}
break;
case 72:
case 73:
choice--;
if(choice==-1)
choice=4;
selectbox(choice,menu[choice]);
for(i=0;i<=4;i++)
{
if(i==choice) continue;
box(i,menu[i]);
}
}
}
pressbutton(choice,menu[choice]);
closegraph();
restorecrtmode();
clrscr();
/*textcolor(4);*/
fm=fopen("c:\movie.txt","rb+");
if(fm==NULL)
fm=fopen("c:\movie.txt","wb+");
switch(choice)
{
case 0:
addmov();
break;
case 1:
listmov();
break;
case 2:
searchmov();
break;
case 3:
main_menu();
break;
case 4:
fclose(fm);
exit(1);
}
}
transactions()
{
char *menu[]={
"NEW TRANSACTION",
"CLOSE TRANSACTION",
"LIST TRANSACTIONS",
"SEARCH MOVIE",
"BACK TO MAIN MENU",
"EXIT"
};
char ch;
int gd=DETECT,gm,i,choice=0;
initgraph(&gd,&gm,PATH);
setfillstyle(SOLID_FILL,RED);
bar(0,0,640,480);
title("TRANSACTION MENU",100);
status();
box(0,menu[0]);
box(1,menu[1]);
box(2,menu[2]);
box(3,menu[3]);
box(4,menu[4]);
box(5,menu[5]);
selectbox(choice,menu[choice]);
//72 up
//80 down
//75 left
//77 right
//13 enter
//49 1
//71 Home
//79 End
//73 PgUp
//81 PgDown
//27 Escape
while((ch=getch())!=13)
{
switch(ch)
{
case 80:
case 81:
choice++;
if(choice==6)
choice=0;
selectbox(choice,menu[choice]);
for(i=0;i<=5;i++)
{
if(i==choice) continue;
box(i,menu[i]);
}
break;
case 72:
case 73:
choice--;
if(choice==-1)
choice=5;
selectbox(choice,menu[choice]);
for(i=0;i<=5;i++)
{
if(i==choice) continue;
box(i,menu[i]);
}
}
}
pressbutton(choice,menu[choice]);
closegraph();
restorecrtmode();
clrscr();
ft=fopen("c:\transact.txt","rb+");
if(ft==NULL)
ft=fopen("c:\transact.txt","wb+");
switch(choice)
{
case 0:
addtran();
break;
case 1:
closetran();
break;
case 2:
listtran();
break;
case 3:
fm=fopen("c:\movie.txt","rb+");
if(fm==NULL)
fm=fopen("c:\movie.txt","wb+");
searchmov();
break;
case 4:
main_menu();
break;
case 5:
exit(0);
}
}
addcus()
{
char another='y';
fseek(fc,0,SEEK_END);
TBG;
while(another=='y'||another=='Y')
{
clrscr();
printf("******************** ADD CUSTOMER FORM
**********************");
printf("
CUSTOMER ID(NUMERIC) :
");
printf("CUSTOMER NAME :
");
printf("CUSTOMER PHONE NO :
");
printf("CUSTOMER ADDRESS :
");
printf("DATE OF JOINING :
");
printf("CATEGORY(H/A/C/R/S/T) :
");
gotorc(2,24);
customid();
gotorc(4,24);
fflush(stdin);
gets(ctr.name);
gotorc(6,24);
fflush(stdin);
gets(ctr.pn);
gotorc(8,24);
fflush(stdin);
gets(ctr.address);
gotorc(10,24);
fflush(stdin);
getdate(&d);
ctr.doj[0]=d.da_day;ctr.doj[1]=d.da_mon;ctr.doj[2]=d.da_year;
printf("%d/%d/%d",d.da_day,d.da_mon,d.da_year);
gotorc(12,24);
fflush(stdin);
ctr.category=getche();
gotorc(16,3);
printf("DO YOU WANT TO SUBMIT THIS FORM (Y/N)");
fflush(stdin);
another=getch();
if(another=='y'||another=='Y')
fwrite(&ctr,size,1,fc);
gotorc(18,3);
printf("DO YOU WANT TO ADD ANOTHER CUTOMER(Y/N)");
fflush(stdin);
another=getch();
}
fclose(fc);
customer();
}
customid()
{
rewind(fc);
if(fread(&ctr,sizeof(ctr),1,fc)!=1)
ctr.id=1;
else
{
while(fread(&ctr,sizeof(ctr),1,fc)==1);
ctr.id++;
}
printf("%ld",ctr.id);
}
modify()
{
char another='y',choice,name[20],flag='n';
long id;
TBG;
while(another=='y'||another=='Y')
{
clrscr();
rewind(fc);
printf("
SEARCH BY NAME : PRESS 1
SEARCH BY ID : PRESS
2
");
fflush(stdin);
choice=getchar();
if(choice=='2')
{
printf("
ENTER CUSTOMER ID : ");
scanf("%ld",&id);
while(fread(&ctr,size,1,fc)==1)
{
if(ctr.id==id)
{
new();
flag='y';
break;
}
}
}
if(choice=='1')
{
printf("
ENTER CUSTOMER NAME : ");
fflush(stdin);
gets(name);
while(fread(&ctr,size,1,fc)==1)
{
if(strcmpi(ctr.name,name)==0)
{
new();
flag='y';
break;
}
}
}
if(flag=='n')
{
gotorc(15,3);
printf("CUSTOMER NOT FOUND............ !");
}
gotorc(18,3);
printf("DO YOU WANT TO MODIFY ANOTHER CUTOMER(Y/N)");
fflush(stdin);
another=getch();
}
fclose(fc);
customer();
}
new()
{
char another='y';
clrscr();
TBG;
fseek(fc,-size,SEEK_CUR);
printf("
CUSTOMER'S NEW NAME :
");
printf("CUSTOMER'S NEW PHONE NO :
");
printf("CUSTOMER'S NEW ADDRESS :
");
printf("NEW DATE OF JOINING (DD<-|MM<-|YYYY<-|) :
");
printf("NEW CATEGORY(H/A/C/R/S/T) :
");
gotorc(1,43);
fflush(stdin);
gets(ctr.name);
gotorc(3,43);
fflush(stdin);
gets(ctr.pn);
gotorc(5,43);
fflush(stdin);
gets(ctr.address);
gotorc(7,43);
fflush(stdin);
scanf("%d",&ctr.doj[0]);
gotorc(7,45);
printf("%c",'/');
scanf("%d",&ctr.doj[1]);
gotorc(7,48);
printf("%c",'/');
scanf("%d",&ctr.doj[2]);
gotorc(9,43);
fflush(stdin);
ctr.category=getche();
gotorc(16,3);
printf("UPDATE THE CUSTOMER RECORD (Y/N)");
fflush(stdin);
another=getch();
if(another=='y'||another=='Y')
fwrite(&ctr,size,1,fc);
rewind(fc);
}
listcust()
{
int i=1,p=4;
clrscr();
TBG;
rewind(fc);
printf("****************************** CUSTOMERS LIST
********************************
");
gotorc(2,3);
printf("ID");
gotorc(2,8);
printf("NAME");
gotorc(2,22);
printf("PHONE NO");
gotorc(2,35);
printf("ADDRESS");
gotorc(2,55);
printf("D.O.J");
gotorc(2,68);
printf("CATEGORY");
while(fread(&ctr,size,1,fc)==1)
{
gotorc(p,3);
printf("%ld",ctr.id);
gotorc(p,8);
printf("%s",strupr(ctr.name));
gotorc(p,22);
printf("%s",ctr.pn);
gotorc(p,35);
printf("%s",strupr(ctr.address));
gotorc(p,55);
printf("%d/%d/%d",ctr.doj[0],ctr.doj[1],ctr.doj[2]);
gotorc(p,70);
printf("%c",toupper(ctr.category));
if(i%15==0)
{
gotorc(40,3);
printf("PRESS ANY KEY TO CONTINUE.....");
getch();
clrscr();
p=4;
}
p+=2;
i++;
}
printf("
delete()
{
char another='y',choice,name[20],flag='n';
long id;
tmp=fopen("c:\temp.txt","wb");
rewind(fc);
TBG;
while(another=='y'||another=='Y')
{
clrscr();
printf(" DELETE BY NAME : 1
DELETE BY ID : 2
");
fflush(stdin);
choice=getchar();
if(choice=='2')
{
printf("
ENTER CUSTOMER ID : ");
scanf("%ld",&id);
clrscr();
while(fread(&ctr,size,1,fc)==1)
{
if(ctr.id!=id)
fwrite(&ctr,size,1,tmp);
else
flag='y';
}
}
if(choice=='1')
{
printf("
ENTER CUSTOMER NAME : ");
fflush(stdin);
gets(name);
clrscr();
while(fread(&ctr,size,1,fc)==1)
{
if(strcmpi(ctr.name,name)!=0)
fwrite(&ctr,size,1,tmp);
else
flag='y';
}
}
fclose(fc);
fclose(tmp);
remove("c:\customer.txt");
rename("c:\temp.txt","c:\customer.txt");
if(flag=='n')
printf("
CUSTOMER NOT FOUND.... !");
printf("
DO YOU WANT TO DELETE ANOTHER CUTOMER(Y/N)");
fflush(stdin);
another=getch();
}
fclose(fc);
customer();
}
addmov()
{
char another='y';
TBG;
fseek(fm,0,SEEK_END);
while(another=='y'||another=='Y')
{
clrscr();
printf("**********************ADD MOVIE FORM
**************************");
printf("
MOVIE ID(NUMERIC) :
");
printf("MOVIE NAME :
");
printf("NO OF COPIES :
");
printf("SUPPLIER ID :
");
printf("LOCATION :
");
gotorc(1,24);
movid();
gotorc(2,24);
fflush(stdin);
gets(mv.title);
gotorc(3,24);
fflush(stdin);
scanf("%d",&mv.copy);
mv.cponshelf=mv.copy;
mv.issue=0;
gotorc(4,24);
fflush(stdin);
gets(mv.sid);
gotorc(5,24);
fflush(stdin);
scanf("%d",&mv.loc);
fwrite(&mv,sizeof(mv),1,fm);
printf("
DO YOU WANT TO ADD ANOTHER MOVIE(Y/N)");
fflush(stdin);
another=getch();
}
fclose(fm);
printf("
PRESS ANY KEY TO BACK TO MOVIE MENU");
movie();
}
movid()
{
rewind(fm);
if(fread(&mv,sizeof(mv),1,fm)!=1)
mv.id=1;
else
{
while(fread(&mv,sizeof(mv),1,fm)==1);
mv.id++;
}
printf("%ld",mv.id);
}
listmov()
{
int i=1,p=4;
textbackground(WHITE);
textcolor(BLUE);
clrscr();
rewind(fm);
printf("****************************** MOVIE LIST
********************************");
gotorc(2,1);
printf("ID");
gotorc(2,5);
printf("TITLE");
gotorc(2,25);
printf("TOT_CP");
gotorc(2,35);
printf("CP_O_SHELF");
gotorc(2,48);
printf("TOT_ISSUES");
gotorc(2,59);
printf("SUPPLIER ID");
gotorc(2,71);
printf("LOCATION");
while(fread(&mv,sizeof(mv),1,fm)==1)
{
gotorc(p,1);
printf("%ld",mv.id);
gotorc(p,5);
printf("%s",strupr(mv.title));
gotorc(p,28);
printf("%d",mv.copy);
gotorc(p,40);
printf("%d",mv.cponshelf);
gotorc(p,52);
printf("%d",mv.issue);
gotorc(p,59);
printf("%s",mv.sid);
gotorc(p,74);
printf("%d",mv.loc);
if(i%10==0)
{
printf("
PRESS ANY KEY TO CONTINUE.....");
fflush(stdin);
getch();
clrscr();
p=4;
}
i++;
p+=2;
}
printf("
searchmov()
{
char mname[20],another;
TBG;
clrscr();
rewind(fm);
gotorc(5,5);
printf("ENTER MOVIE TITLE : ");
fflush(stdin);
gets(mname);
while(fread(&mv,sizeof(mv),1,fm)==1)
{
if(strcmpi(mv.title,mname)==0)
{
gotorc(7,12);
textcolor(0);
cprintf("MOVIE FOUND..");
textcolor(4);
gotorc(9,5);
printf("MOVIE TITLE : %s",mv.title);
gotorc(11,5);
printf("TOTAL NO OF COPIES : %d",mv.copy);
gotorc(13,5);
printf("NO OF COPIES AVAILABLE : %d",mv.cponshelf);
gotorc(15,5);
printf("SUPPLIER ID : %s",mv.sid);
gotorc(17,5);
printf("LOCATION : %d",mv.loc);
gotorc(20,5);
printf("DO YOU WANT TO SEARCH MORE MOVIES(Y/N)");
fflush(stdin);
another=getchar();
if(another=='y'||another=='Y')
searchmov();
fclose(fm);
movie();
}
}
gotorc(7,5);
textcolor(4);
cprintf("MOVIE NOT FOUND.....!");
textcolor(4);
gotorc(12,5);
printf("DO YOU WANT TO SEARCH MORE MOVIES(Y/N)");
fflush(stdin);
another=getchar();
if(another=='y'||another=='Y')
searchmov();
fclose(fm);
movie();
addtran()
{
char another='y',rec;
TBG;
fseek(ft,0,SEEK_END);
while(another=='y'||another=='Y')
{
clrscr();
printf("************************ TRANSACTION
*************************");
printf("
INVOICE NO(NUMERIC) :
");
printf("MOVIE TITLE :
");
printf("COPIES AVAILABLE :
");
printf("CUSTOMER ID :
");
printf("CUSTOMER NAME :
");
printf("NO. OF COPIES :
");
printf("DATE OF ISSUE :
");
gotorc(2,24);
invoice();
gotorc(4,24);
fflush(stdin);
gets(tran.title);
gotorc(6,24);
avail();
gotorc(8,24);
fflush(stdin);
scanf("%ld",&tran.cid);
custcheck();
gotorc(12,24);
fflush(stdin);
scanf("%d",&tran.copies);
if(tran.copies>mv.cponshelf)
{
gotorc(18,3);
printf("
TRANSACTION NOT POSSIBLE :
custcheck()
{
if((fc=fopen("c:\customer.txt","rb"))==NULL)
fc=fopen("c:\customer.txt","wb+");
rewind(fc);
while(fread(&ctr,sizeof(ctr),1,fc)==1)
{
if(ctr.id==tran.cid)
{
gotorc(10,24);
printf("%s",ctr.name);
strcpy(tran.cname,ctr.name);
fclose(fc);
return;
}
}
fclose(fc);
gotorc(18,4);
printf("INVALID CUSTOMER ............!");
gotorc(21,4);
printf("
PRESS ANY KEY TO BACK TO TRANSACTION MENU");
getch();
transactions();
invoice()
{
rewind(ft);
if(fread(&tran,sizeof(tran),1,ft)!=1)
tran.invoice=1;
else
{
while(fread(&tran,sizeof(tran),1,ft)==1);
tran.invoice++;
}
printf("%ld",tran.invoice);
}
avail()
{
fm=fopen("c:\movie.txt","rb+");
if(fm==NULL)
fm=fopen("c:\movie.txt","wb+");
while(fread(&mv,sizeof(mv),1,fm)==1)
{
if(strcmpi(tran.title,mv.title)==0)
{
printf("%d",mv.cponshelf);
fclose(fm);
return;
}
}
gotorc(18,3);
printf("%s","MOVIE NOT FOUND...!");
gotorc(21,3);
printf("PRESS ANY KEY TO RETURN");
getch();
fclose(fm);
transactions();
}
update()
{
long msize;
msize=sizeof(mv);
fm=fopen("c:\movie.txt","rb+");
if(fm==NULL)
fm=fopen("c:\movie.txt","wb+");
while(fread(&mv,sizeof(mv),1,fm)==1)
{
if(strcmpi(tran.title,mv.title)==0)
{
mv.cponshelf=mv.cponshelf-tran.copies;
mv.issue=mv.issue+tran.copies;
fseek(fm,-msize,SEEK_CUR);
fwrite(&mv,sizeof(mv),1,fm);
break;
}
}
fclose(fm);
return;
}
listtran()
{
int i=1;
TBG;
clrscr();
rewind(ft);
while(fread(&tran,sizeof(tran),1,ft)==1)
{
printf("
INVOICE NO(NUMERIC) : %ld
",tran.invoice);
printf("CUSTOMER ID : %ld
",tran.cid);
printf("CUSTOMER NAME : %s
",tran.cname);
printf("MOVIE TITLE : %s
",tran.title);
printf("NO. OF COPIES : %d
",tran.copies);
printf("DATE OF ISSUE :
%d/%d/%d
",tran.doi[0],tran.doi[1],tran.doi[2]);
if(tran.dor[0]!=0)
{
printf("DATE OF RETURN :
%d/%d/%d
",tran.dor[0],tran.dor[1],tran.dor[2]);
printf("RENT : %d
",tran.rent);
printf("FINE : %d
",tran.fine);
printf("TOTAL AMOUNT : %d
",tran.tam);
}
printf("..................................................................
");
if(i%2==0)
{
printf("
PRESS ANY KEY TO CONTINUE.....");
getch();
clrscr();
}
i++;
}
fclose(ft);
printf("
PRESS ANY KEY TO BACK TO TRANSACTION MENU");
getch();
transactions();
}
closetran()
{
long id,sz;
TBG;
clrscr();
sz=sizeof(tran);
printf("
ENTER INVOICE NO: ");
scanf("%ld",&id);
clrscr();
while(fread(&tran,sz,1,ft)==1)
{
if(tran.invoice==id)
{
if(tran.dor[0]!=0)
{
gotorc(4,4);
printf("THIS TRANSACTION IS ALL READY CLOSED...!");
gotorc(7,4);
printf("PRESS ANY KEY TO BACK TO TRANSACTION
MENU......");
getch();
transactions();
}
fseek(ft,-sz,1);
getdate(&d);
tran.dor[0]=d.da_day;tran.dor[1]=d.da_mon;tran.dor[2]=d.da_year;
difference();
tran.rent=tran.copies*25;
if(k==0)
tran.fine=0;
else
tran.fine=tran.copies*(k-1)*5;
tran.tam=tran.rent+tran.fine;
printf("
INVOICE NO(NUMERIC) : %ld
",tran.invoice);
printf("CUSTOMER ID : %ld
",tran.cid);
printf("CUSTOMER NAME : %s
",tran.cname);
printf("MOVIE TITLE : %s
",tran.title);
printf("NO. OF COPIES : %d
",tran.copies);
printf("DATE OF ISSUE :
%d/%d/%d
",tran.doi[0],tran.doi[1],tran.doi[2]);
printf("DATE OF RETURN :
%d/%d/%d
",tran.dor[0],tran.dor[1],tran.dor[2]);
printf("RENT : %d
",tran.rent);
printf("FINE : %d
",tran.fine);
printf("TOTAL AMOUNT : %d
",tran.tam);
updateclose();
fwrite(&tran,sz,1,ft);
fclose(ft);
}
}
printf("
PRESS ANY KEY TO BACK TO TRANSACTION MENU");
getch();
transactions();
difference()
{
int t,m1,m2,y1,y2,d1,d2;
d1=tran.doi[0];
d2=tran.dor[0];
m1=tran.doi[1];
m2=tran.dor[1];
y1=tran.doi[2];
y2=tran.dor[2];
t=m1;
if(y2>y1)
{
while(y2>y1)
{
while(m1<=12)
{
check(m1,y1);
if(m1==t)
k=days-d1;
else
k=k+days;
m1=m1+1;
}
m1=1;y1++;
}
while(m1<m2)
{
check(m1,y1);
k=k+days;
m1++;
}
k=k+d2;
}
else
{
if(m1!=m2)
{
while(m1<m2)
{
check(m1,y1);
if(m1==t)
k=days-d1;
else
k=k+days;
m1=m1+1;
}
k=k+d2;
}
else
k=d2-d1;
}
gotorc(int r,int c)
{
union REGS i,o;
i.h.ah=2;
i.h.bh=0;
i.h.dh=r;
i.h.dl=c;
int86(16,&i,&o);
}
screen1()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,PATH);
setfillstyle(SOLID_FILL,RED);
bar(0,0,640,480);
setfillstyle(SOLID_FILL,WHITE);
bar(15,15,625,465);
setfillstyle(SOLID_FILL,RED);
bar(30,30,610,450);
settextstyle(1,0,8);
setcolor(WHITE);
outtextxy(190,35,"VIDEO");
setfillstyle(SOLID_FILL,LIGHTGRAY);
bar3d(180,140,385,130,20,20);
outtextxy(160,150,"LIBRARY");
bar3d(140,255,440,245,20,20);
outtextxy(165,270,"SYSTEM");
bar3d(145,375,440,365,20,20);
/* sleep(4); */
getch();
closegraph();
restorecrtmode();
}
screen2()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,PATH);
setfillstyle(SOLID_FILL,RED);
bar(0,0,640,480);
setfillstyle(SOLID_FILL,WHITE);
bar(15,15,625,465);
setfillstyle(SOLID_FILL,RED);
bar(30,30,610,450);
setfillstyle(SOLID_FILL,LIGHTGRAY);
bar3d(180,100,420,300,25,25); /*members bar*/
settextstyle(1,1,10);
setcolor(WHITE);
outtextxy(10,55,"IIMS");
setfillstyle(SOLID_FILL,LIGHTGRAY);
bar3d(180,50,420,70,20,20); /*project members bar*/
bar3d(50,350,570,420,25,25); /*project guide bar*/
setcolor(BLUE);
settextstyle(1,0,2);
outtextxy(193,48,"PROJECT MEMBERS");
outtextxy(193,130,"MANISH MISHRA");
outtextxy(193,170,"VISHAL YADAV");
outtextxy(193,210,"SHIV KUMAR RAI");
outtextxy(193,250,"DINESH YADAV");
outtextxy(235,351,"PROJECT GUIDE:");
settextstyle(1,0,5);
outtextxy(140,373,"MR. AMIT TANEJA");
/* sleep(4); */
getch();
closegraph();
restorecrtmode();
}
setfillstyle(SOLID_FILL,WHITE);
bar(180,110+55*i,410,140+55*i);
setfillstyle(SOLID_FILL,9);
bar(179,108+55*i,409,138+55*i);
setcolor(CYAN);
settextstyle(1,0,2);
outtextxy(184,110+55*i,p);
delay(350);
}
title(char *title,int x)
{
setfillstyle(SOLID_FILL,9);
bar(0,0,640,50);
setcolor(BLACK);
settextstyle(1,0,5);
outtextxy(x,0,title);
}
status()
{
setfillstyle(SOLID_FILL,9);
bar(0,450,640,480);
setcolor(BLACK);
settextstyle(1,0,3);
outtextxy(30,450,"USE UP & DOWN ARROW KEYS TO SELECT AN
OPTION");
}
void main()
{
screen1();
screen2();
main_menu();
}
Code :
#include<graphics.h>
#include<dos.h>
#include<stdlib.h>
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<process.h>
#include<fstream.h>
#include<dir.h>
#include<stdio.h>
// GLOBAL Funcions
void grap();
void intro();
void box();
void mainwindow();
void faculty();
void student();
void enterdata();
void personaldetial();
void admindetails(char *name);
void seeyearfaculty();
void fullaccessfaculty();
void modifyfaculty();
void deletefaculty();
void prin();
void enterdatast();
void personalst();
void academic(char *name);
void seetotalst();
void fullaccessst();
void modifyst();
void deletest();
void encrypt(char *name);
void closeprog();
void quit();
void typeme(int left,int top,const char *word,int interval);
// GLOBAL Variables
int option,pass,i,access,x,y,status;
char year[10],ch,name[100],temp[200],newfile[100],a[50],mod;
void *p;
size_t area;
void main()
{
grap();
a:clearviewport();
i=0;
rectangle(getmaxx()/2-140,getmaxy()/2-20,getmaxx()/2+135,getmaxy()/2+4);
outtextxy(getmaxx()/2-127,getmaxy()/2-12,"Enter Accesscode:");
gotoxy(43,15);
//Password Code
do
{
pass=getch();
if(pass==13) goto b;
a[i]=char(pass);
cout<<"*";
sound(500);delay(100);nosound();
i++;
}while(pass!=13);
b:a[i]=0;
access=stricmp(a,"nopassword");
if(access==0)
{
cout<<"
Access Granted ..
Press Any Key To Continue.......";
intro();
textcolor(BLACK);
textbackground(YELLOW);
mainwindow();
}
else
{
clearviewport();
cout<<"
Unautorised Access ";
cout<<"
Press Any Key To Continue......... ";
getch();
goto a;
}
}
// INTRODUCTION SCREEN
void intro()
{
int a,b,c,d;
setfillstyle(8,1);
for(a=0,b=getmaxx(),c=getmaxx()/2,d=getmaxx()/2;a<getmaxx()/2+3;a+=5,b-=5,
c-=5,d+=5)
{
line(c,xy(8),d,xy(8));line(c,xy(51),d,xy(51));
bar(0,xy(9),a,xy(50));bar(b,xy(9),getmaxx(),xy(50));
sound(10*(a+250));delay(10);
}
nosound();
char pattern[] ={0xfe,0xbc,0xda,0xe4,0xe2,0xc0,0x88,0x00};
setfillpattern(pattern,1);
bar(0,0,640,480);
settextstyle(1,0,5);
setcolor(10);
outtextxy(100,140,"INSTITUTE MANAGEMENT");
outtextxy(250,200,"SYSTEM");
getch();
setcolor(0);
for(i=0;i<=320;i++)
{
rectangle(0+i,0,640-i,480);
delay(5);
}
closegraph();
}
// DETECTION OF GRAPHICS
void grap()
{
int gd= DETECT, gm, errorcode;
initgraph(&gd, &gm, "c:\tc\bgi");
errorcode = graphresult();
if(errorcode != grOk)
{
printf("Graphics error: %s
", grapherrormsg(errorcode));
exit(1);
}
void box(void)
{
int i,x,y;
gotoxy(11,2);
gotoxy(11,6);
gotoxy(68,2);
putch(191);
y=3;
gotoxy(68,24);
putch(217);
gotoxy(11,24);
for(i=1; i<=57; i++)
{
putch(196);
}
gotoxy(11,24);
putch(192);
y=3;
gotoxy(11,2);
putch(218);
void mainwindow()
{
clrscr();
box();
cin>>option;
switch(option)
{
case 1 : faculty();
break;
case 2 : student();
break;
case 3 : prin();
break;
default : closeprog();
break;
};
}
void faculty()
{
clrscr();
box();
cin>>option;
switch(option)
{
case 1 : enterdata();
break;
case 2 : seeyearfaculty();
break;
case 3 : fullaccessfaculty();
break;
case 4 : modifyfaculty();
break;
case 5 : deletefaculty();
break;
default : closeprog();
break;
};
}
void enterdata()
{
clrscr();
cout<<"
Enter The Year Which you Want To Add The Data ";
cout<<"
============================================= ";
gets(year);
mkdir("data");
chdir("data");
mkdir("faculty");
chdir("faculty");
mkdir(year);
chdir(year);
cout<<"
Enter The Faculty Name : ";
gets(name);
mkdir(name);
chdir(name);
personaldetial();
chdir("\");
mainwindow();
}
mkdir(name);
chdir(name);
strcpy(newfile,"p");
strcat(newfile,name);
strcat(newfile,".txt");
ofstream fout(newfile);
if(!fout)
{
clrscr();
perror("
fout<<"NAME : "<<name;
cout<<"
Enter The Address : ";
gets(temp);
fout<<"
ADDRESS :"<<temp;
cout<<"
Enter Contact No. : ";
gets(temp);
fout<<"
CONTACT No. :"<<temp;
fout.close();
encrypt(newfile);
admindetails(name);
}
cout<<"
strcpy(newfile,"a");
strcat(newfile,name);
strcat(newfile,".txt");
ofstream foutt(newfile);
if(!foutt)
{
clrscr();
perror("
foutt<<"NAME : "<<name;
cout<<"
foutt<<"
EDUCATIONAL QUALIFICATIONS :"<<temp;
cout<<"
Enter The Name Of The Subjects Taught ";
cout<<"
===================================== ";
foutt<<"
SUBJECTS TAUGHT :";
cout<<"
foutt<<"
cout<<"
Type Of Subject (Theory / Practical) :";
gets(temp);
foutt<<"
Type of Subject :"<<temp;
cout<<"
foutt<<"
foutt<<"
Type of Subject :"<<temp;
cout<<"
foutt<<"
cout<<"
Type Of Subject (Theory / Practical) :";
gets(temp);
foutt<<"
Type of Subject :"<<temp;
cout<<"
Enter Type of Faculty (Permanent / Visiting)";
gets(temp);
foutt<<"
TYPE OF FACULTY :"<<temp;
foutt.close();
encrypt(newfile);
while(fin)
{
fin.get(ch);
if(ch==EOF)break;
mod=~ch;
fout<<mod;
}
remove(newfile);
rename("temp.txt",newfile);
}
void seeyearfaculty()
{
clrscr();
cout<<"
";
gets(year);
chdir("data");
chdir("faculty");
chdir(year);
cout<<"
chdir(name);
clrscr();
cout<<"
";
cout<<"
";
system("dir /b /ad /w");
getch();
chdir("\");
mainwindow();
}
void fullaccessfaculty()
{
clrscr();
chdir("data");
chdir("faculty");
cout<<"
chdir(year);
cout<<"
chdir(name);
cout<<"
chdir(name);
cout<<"
What You Want To See Personal Information Or Admin
Information
";
cout<<"
1. Personal ";
cout<<"
2. Adminstration ";
cout<<"
Option------> ";
cin>>option;
clrscr();
cout<<"
";
if(option==1)
{
strcpy(newfile,"p");
strcat(newfile,name);
strcat(newfile,".txt");
ifstream fin(newfile);
if(!fin)
{
clrscr();
perror("
while(fin.get(ch)!=0)
{
mod=~ch;
cout<<mod;
}
getch();
fin.close();
}
if(option==2)
{
strcpy(newfile,"a");
strcat(newfile,name);
strcat(newfile,".txt");
ifstream fin(newfile);
if(!fin)
{
clrscr();
perror("
while(fin.get(ch)!=0)
{
mod=~ch;
cout<<mod;
}
getch();
fin.close();
}
chdir("\");
mainwindow();
}
void modifyfaculty()
{
clrscr();
chdir("data");
chdir("faculty");
cout<<"
chdir(year);
cout<<"
chdir(name);
cout<<"
status=rmdir(name);
if(status==0)
{
personaldetial();
}
else
{
clrscr();
perror("
void deletefaculty()
{
clrscr();
chdir("data");
chdir("faculty");
cout<<"
chdir(year);
cout<<"
chdir(name);
cout<<"
cout<<"
if(ch=='y')
{
status=rmdir(name);
if(status==0)
{
cout<<"
Record Have Been Removed Succesfully ";
cout<<"
Press Any Key To Return To Main Menu ";
getch();
chdir("\");
mainwindow();
}
else
{
clrscr();
perror("
else
{
chdir("\");
mainwindow();
}
}
void prin()
{
clrscr();
cout<<"
Enter The Option ";
cout<<"
1. Faculty ";
cout<<"
2. Student ";
cout<<"
Option------> ";
cin>>option;
chdir("data");
if(option==1)
{
chdir("faculty");
cout<<"
Enter The Year ";
gets(year);
chdir(year);
cout<<"
Enter The Name Of Faculty ";
gets(name);
chdir(name);
cout<<"
Want Take A Print Document Of Personal Or Admin Details ";
cout<<"
1. Personal ";
cout<<"
2. Adminstration ";
cout<<"
Option------> ";
cin>>option;
if(option==1)
{
strcpy(newfile,"p");
strcat(newfile,name);
strcat(newfile,".txt");
ifstream fin;
fin.open(newfile);
if(!fin)
{
clrscr();
perror("
ofstream fout;
fout.open("PRN");
if(!fout)
{
clrscr();
perror("
while(fin.get(ch)!=0)
{
mod=~ch;
fout.put(mod);
}
fout.close();
fin.close();
}
if(option==2)
{
strcpy(newfile,"a");
strcat(newfile,name);
strcat(newfile,".txt");
ifstream fin;
fin.open(newfile);
if(!fin)
{
clrscr();
perror("
ofstream fout;
fout.open("PRN");
if(!fin)
{
clrscr();
perror("
fout.close();
fin.close();
}
}
if(option==2)
{
chdir("student");
cout<<"
Enter The Year ";
gets(year);
chdir(year);
cout<<"
Enter The Name Of Student ";
gets(name);
chdir(name);
cout<<"
Want Take A Print Document Of Personal Or Admin Details ";
cout<<"
1. Personal ";
cout<<"
2. Academic ";
cout<<"
Option------> ";
cin>>option;
if(option==1)
{
strcpy(newfile,"p");
strcat(newfile,name);
strcat(newfile,".txt");
ifstream fin;
fin.open(newfile);
if(!fin)
{
clrscr();
perror("
ofstream fout;
fout.open("PRN");
if(!fout)
{
clrscr();
perror("
while(fin.get(ch)!=0)
{
mod=~ch;
fout.put(mod);
}
fout.close();
fin.close();
}
if(option==2)
{
strcpy(newfile,"a");
strcat(newfile,name);
strcat(newfile,".txt");
ifstream fin;
fin.open(newfile);
if(!fin)
{
clrscr();
perror("
ofstream fout;
fout.open("PRN");
if(!fout)
{
clrscr();
perror("
while(fin.get(ch)!=0)
{
mod=~ch;
fout.put(mod);
}
fout.close();
fin.close();
}
}
chdir("\");
mainwindow();
}
void student()
{
clrscr();
box();
cin>>option;
switch(option)
{
case 1 : enterdatast();
break;
case 2 : seetotalst();
break;
case 3 : fullaccessst();
break;
case 4 : modifyst();
break;
case 5 : deletest();
break;
default : closeprog();
break;
};
}
void enterdatast()
{
clrscr();
cout<<"
Enter The Year Which you Want To Add The Data ";
cout<<"
=============================================== ";
gets(year);
mkdir("data");
chdir("data");
mkdir("student");
chdir("student");
mkdir(year);
chdir(year);
personalst();
chdir("\");
mainwindow();
}
void personalst()
{
cout<<"
cout<<"
mkdir(name);
chdir(name);
strcpy(newfile,"p");
strcat(newfile,name);
strcat(newfile,".txt");
ofstream fout(newfile);
if(!fout)
{
clrscr();
perror("
cout<<"
Fathers Name : ";
gets(temp);
fout<<"
Fathers Name : "<<temp;
cout<<"
Date Of Birth : ";
gets(temp);
fout<<"
Date Of Birth : "<<temp;
cout<<"
Contact Number : ";
gets(temp);
fout<<"
Contact Number : "<<temp;
cout<<"
Address : ";
gets(temp);
fout<<"
ADDRESS :"<<temp;
cout<<"
Course Name : ";
gets(temp);
fout<<"
Course Name : "<<temp;
fout.close();
encrypt(newfile);
academic(name);
}
cout<<"
strcpy(newfile,"a");
strcat(newfile,name);
strcat(newfile,".txt");
ofstream foutt(newfile);
if(!foutt)
{
clrscr();
perror("
cout<<"
Type Of Course (Semster/Annual) : ";
gets(temp);
foutt<<"
Type Of Course (Semester/Annual) : "<<temp;
cout<<"
Year Of Admission : ";
gets(temp);
foutt<<"
Year Of Admission : "<<temp;
cout<<"
Admission Number : ";
gets(temp);
foutt<<"
Admission Number : "<<temp;
cout<<"
Percentage In Intermediate : ";
gets(temp);
foutt<<"
Percentage In Intermediate : "<<temp;
cout<<"
Percentage In College :";
foutt<<"
Percentage In College : ";
cout<<"
First Year : ";
gets(temp);
foutt<<"
First Year :"<<temp;
cout<<"
Second Year : ";
gets(temp);
foutt<<"
Second Year :"<<temp;
cout<<"
Third Year : ";
gets(temp);
foutt<<"
third Year :"<<temp;
foutt.close();
encrypt(newfile);
}
void seetotalst()
{
clrscr();
chdir("data");
chdir("student");
cout<<"
chdir(year);
cout<<"
getch();
chdir("\");
mainwindow();
}
void fullaccessst()
{
clrscr();
chdir("data");
chdir("student");
cout<<"
chdir(year);
cout<<"
chdir(name);
cout<<"
Option------> ";
cin>>option;
clrscr();
cout<<"
";
if(option==1)
{
strcpy(newfile,"p");
strcat(newfile,name);
strcat(newfile,".txt");
ifstream fin(newfile);
if(!fin)
{
clrscr();
perror("
while(fin.get(ch)!=0)
{
mod=~ch;
cout<<mod;
}
getch();
fin.close();
}
if(option==2)
{
strcpy(newfile,"a");
strcat(newfile,name);
strcat(newfile,".txt");
ifstream fin(newfile);
if(!fin)
{
clrscr();
perror("
while(fin.get(ch)!=0)
{
mod=~ch;
cout<<mod;
}
getch();
fin.close();
}
chdir("\");
mainwindow();
}
void modifyst()
{
chdir("data");
chdir("student");
cout<<"
Enter The Year Of You Want To Change The Information : ";
gets(year);
chdir(year);
cout<<"
status=rmdir(name);
if(status==0)
{
personalst();
}
else
{
clrscr();
perror("
chdir("\");
mainwindow();
}
void deletest()
{
clrscr();
chdir("data");
chdir("student");
cout<<"
chdir(year);
cout<<"
cout<<"
if(ch=='y')
{
status=rmdir(name);
if(status==0)
{
cout<<"
else
{
clrscr();
perror("
else
{
chdir("\");
mainwindow();
}
}
void closeprog()
{
grap();
setcolor(6);
for(i=0;i<=220;i++)
{
rectangle(0+i,0+i,640-i,480-i);
delay(15);
}
for(i=0;i<=220;i++)
{
rectangle(100+i,100,540-i,380);
delay(10);
}
quit();
closegraph();
exit(0);
}
void quit()
{
int a,b,c;
setcolor(0);
for(a=1,b=getmaxy()-1,c=200;a<=getmaxy()/2;a++,b--,c--)
{
line(1,a,getmaxx()-1,a);
line(1,b,getmaxx()-1,b);
sound(10*(c+200));
delay(1);
}
delay(300);
nosound();
setcolor(4);
typeme(xy(2),xy(26),"EMAIL ME AT urloginid@yahoo.co.in",30);
delay(2000);
}
#include<fstream.h>
#include<process.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<dos.h>
void res_menu();
void help();
void colyb() {textcolor(YELLOW);textbackground(BLUE);}
void coldes(int a,int b) {textcolor(a);textbackground(b);}
void s(int i,int j)
{
for(int a=i;a>0;a-=j)sound (a);
}
void saund(int j)
{
j=0;
for(int i=20;i<20000;i+=1000)
{sound(i);delay(j);nosound();}
}
class address{ protected :
char hno[10],city[30],post[30],colony[30],pin[10];
public :
void address_inp()
{
cout<<"
House No. : ";gets(hno);
cout<<"
Colony :
";gets(colony);
cout<<"
Post : ";gets(post);
cout<<"
City : ";gets(city);
cout<<"
Pin Code No. : ";gets(pin);
}
void address_out()
{
cout<< hno<<" , "<<colony<<" , "<<post<<" ,
"
<<city<<" - "<<pin;
}
};
class p_det
{
protected :
address add;
float age;
char name[40];
char sex;
public:
void p_det_inp()
{ colyb();
cout<<"
Enter Name : ";gets(name);
cout<<"
Enter address ";
add.address_inp();
cout<<"
Enter age (Years.Months) :
";cin>>age;
cout<<"
Enter sex group (M / F) :
";cin>>sex;
}
void p_det_out()
{ colyb();
cout<<"
PERSONAL DETAILS";
cout<<"
Name :
";puts(name);
cout<<"
Adress : ";
add.address_out();
cout<<"
Age (Years.Months) : ";cout<<age;
cout<<"
Sex group (M/F) : ";cout<<sex;
delay(500);
}
int dd,mm,yy;
public :
void dat_inp()
{
h:
cout<<" date :
dd : ";cin>>dd;
cout<<" mm : ";cin>>mm;
if((dd>31) || (mm>12))
{
cout<<"the date is invalid";
goto h;
}
cout<<" yy : ";cin>>yy;
}
void dat_out()
{
if( (dd>0 && dd<31) && (mm>0 && mm <13) )
{
cout<<"
DATE : "
<<dd<<" # "<<mm<<" # "<<yy;
delay(500);
}
}
};
class res :public dat
{
char fcode[5];char to[15],from[15],via[15];
float fare;
public :
p_det p;
void dest_out(){cout<<"
from : ";puts(from);cout<<"
via
:
";puts(via);cout<<"
to : ";puts(to);}
void res_inp()
{ textcolor(RED); clrscr();
res_menu();
cout<<"
RESERVATION FORM";
cout<<"
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ";
cout<<"
Enter flight code : ";gets(fcode);
if( strcmp(fcode,"0871")==0 )
{
strcpy(from,"LUCKNOW");strcpy(to,"DELHI");strcpy(via,"ÄÄ");
fare=100;
}
else if(strcmp(fcode,"0037")==0)
{
strcpy(from,"LUCKNOW");strcpy(to,"CHENNAI");strcpy(via,"DELHI");
fare=700;
}
else if(strcmp(fcode,"1070")==0)
{
strcpy(from,"DELHI");strcpy(to,"COCHIN");strcpy(via,"ÄÄ");
fare=730;
}
else if(strcmp(fcode,"1007")==0)
{
strcpy(from,"DELHI");strcpy(to,"BANGALORE");strcpy(via,"ÄÄ");
fare=800;
}
else if(strcmp(fcode,"1017")==0)
{
strcpy(from,"LUCKNOW");strcpy(to,"BANGALORE");strcpy(via,"DELHI");
fare=850;
}
else if(strcmp(fcode,"7001")==0 )
{
strcpy(from,"ALLAHBAD");strcpy(to,"DELHI");strcpy(via,"ÄÄ");
fare=80;
}
else
{ coldes(1+128,0);clrscr();
cout<<"
ERROR";saund(30);delay(1000);
strcpy(from,"ERROR");strcpy(to,"ERROR");strcpy(via,"ERROR");exit(0);
}
p.p_det_inp();
dat_inp();
getch();
clrscr();
}
void res_out()
{
cout<<"
RESERVATION ENTRIES";
cout<<"
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ";
cout<<"
Flight Code : ";puts(fcode);
p.p_det_out();
dest_out();
dat_out();
}
friend void assign_code(res p,char str[]);
};
void assign_code(res p,char str[])
{
strcpy(str,p.fcode);
}
void menu()
{
coldes(13,9);clrscr();
clrscr();
cout<<"
MENU";
cout<<"
ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ";
cout<<"
1 . Reservation";
cout<<"
2 . Querries";
cout<<"
3 . Cancellation";
cout<<"
4 . Help";
cout<<"
5 . Exit";
cout<<"
ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ";
delay(1200);
cout<<"
";
textcolor(BLINK+YELLOW);
cprintf(" Press any key to
continue ...");
getch();
textcolor(YELLOW);
}
void res_menu()
{
textcolor(YELLOW);textbackground(8);
cout<<"
";saund(15);
cout<<" ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
";
cout<<" ³ SAHARA AIRLINES ³
";
cout<<" ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ1/4
";
cout<<" RESERVATION / ROUTE / FARE MENU
";saund(15);
cout<<" ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
";saund(15);
cout<<"ÛÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
ÜÜÜÜÜÜÜÜÜÜÜÜ ";s(10000,500);
cout<<" ³ SN ³ FROM ³ TO ³ VIA ³F.CODE³ TIMING ³
DAY
³ FARE ³ ";s(10000,500);
cout<<" ³ ³ ³ ³ ³ ³ (ARR)³(DEP) ³
³ ($) ³ ";s(10000,500);
cout<<" ³ 1 ³ LUCKNOW ³ DELHI ³ ßßßßß ³ 0871 ³ 1530 ³ 1615 ³
MONDAY ³ 100 ³ ";s(10000,500);
cout<<" ³ 2 ³ LUCKNOW ³ CHENNAI ³ DELHI ³ 0037 ³ 1200 ³ 1230 ³
THURSDAY ³ 700 ³ ";s(10000,500);
cout<<" ³ 3 ³ DELHI ³ COCHIN ³ ßßßßß ³ 1070 ³ 1740 ³ 1830 ³
FRIDAY ³ 730 ³ ";s(10000,500);
cout<<" ³ 4 ³ DELHI ³ BANGALORE³ ßßßßß ³ 1007 ³ 2040 ³ 2100 ³
SUNDAY ³ 800 ³ ";s(10000,500);
cout<<" ³ 5 ³ LUCKNOW ³ BANGALORE³ DELHI ³ 1017 ³ 1615 ³ 1700 ³
MONDAY ³ 850 ³ ";s(10000,500);
cout<<" ³ 6 ³ ALLAHBAD ³ DELHI ³ ÄÄÄÄÄ ³ 7001 ³ 0845 ³ 0910 ³
SUNDAY ³ 80 ³"; s(10000,500);
cout<<"ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
ÛÛÛÛÛÛÛÛÛÛÛÛÛ ";s(10000,500);
delay(1000);
saund(50);
textcolor(BLINK+YELLOW);
cprintf(" Press any to continue
...");
getch();
void main()
{
textcolor(12);
textbackground(8);
int mch;
res r;
int flag=0,rec=0;
char ch;
do { clrscr();
saund(50);
//if(oo>0)restart();oo++;
char name[36],code[5],name1[36],code1[5];
char name2[36],code2[5];
int flag=0;
fstream fin,fin1;
textcolor(YELLOW);
menu();
saund(30);
gotoxy(4,15);
//ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄ
// CASE 1 : WRITING
//###################################3##################################
##
#####
case 1: r.res_inp();
fin.open("oldmas.dat",ios::binary |ios::app);
fin.write( (char *) &r,sizeof(r));
fin.close();
fin.open("oldmas.dat",ios::binary |ios::in);
fin1.open("newmas.dat",ios::binary |ios::out);
fin.read( (char*)&r,sizeof(res) );
while(!fin.eof() )
{
fin1.write( (char*)&r,sizeof(res) );
fin.read( (char*)&r,sizeof(res) );
}
fin.close();
fin1.close();
break;
//ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄ
// C A S E : 2 " S E A R C H I N G"
//######################################################################
##
#####
case 2:
fin.open("newmas.dat",ios::in|ios::binary);
cout<<"
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
Ä";
cout<<"
Enter the name : ";gets(name);
cout<<"
Enter the flight code : ";gets(code);
while( !fin.eof() )
{
assign_code(r,code1);
r.p.assign_name(r.p,name1);
if(strcmpi(name1,name)==0 && strcmp(code1,code)==0)
{
clrscr();
cout<<"
aÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ";
cout<<"
a Welcome to `Sahara Querries' ";
cout<<"
aÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ";
r.res_out();
rec=1;
cout<<"
aÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ";
cout<<"aÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄ";
cout<<" Press any key to continue"; getch();
}
fin.read((char *)&r , sizeof(res));
}
fin.close(); clrscr();
if(rec==0)
{
coldes(14+128,0);
clrscr();
cout<<"
break;
//ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄ
// CASE:3 "CANCLATION"
//######################################################################
##
#########
case 3:
cout<<"
enter the name ";
gets(name);
cout<<"
enter the code ";
gets(code);
cout<<"
Checking for record";
fin.open("oldmas.dat",ios::binary | ios::in);
fin1.open("newmas.dat",ios::binary | ios::out);
if(fin==NULL && fin1==NULL)
{
cout<<" No records found in Reservation Master";getch();
goto label;
}
else
{ fin.read( (char*)&r,sizeof(res) );
while(!fin.eof() )
{
assign_code(r,code1);
r.p.assign_name(r.p,name1);// cout<<"
name 1 & code1 :
";puts(name1);puts(code1);getch();
if(strcmpi(name1,name)==0 && strcmp(code1,code)==0)
{
cout<<"
record found ";
cout<<"
Deleting.a.a.a.a.";
}
else
{
fin1.write( (char*)&r ,sizeof(res));
}
fin.read( (char*)&r,sizeof(res) );
}
}
fin.close();fin1.close();
cout<<"
label :
break;
//ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄ
// CASE 4:HELP
//######################################################################
##
#####
case 4:help();break;
//ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄ
// CASE 5:EXIT
//######################################################################
##
######
case 5:
// for(int a=1;a<5;a++)
{
textcolor(YELLOW+BLINK);clrscr();
puts("
Exiting . . .
please wait");
saund(70);
// delay(10);nosound();saund(20);nosound();delay(150);
}
exit(1);
break;
default :
cout<<"Out of choice !!!
Try Again (y/n) : ";
cin>>ch; break;
}
// END OF SWITCH
}while( (mch>0 && mch<6) || (ch=='y' || ch=='Y') );
delay(2000);
}
//ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄ
// END OF MAIN
//######################################################################
##
######
//ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄ
// HELP MENU
//######################################################################
##
######
void help()
{ coldes(13,8);
clrscr();
cout<<"
Welcome to online 'HELP'";
delay(700);
cout<<"
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄ";
cout<<"
You are provided with irlines 'MENU'
";
cout<<"
According to your need , you may
";
cout<<"
choose any valid option & enter your
";
cout<<"
choice . ";
delay(2000);
cout<<"
Example ";delay(700);
clrscr();
delay(1500);
cout<<"
Welcome to online 'HELP'";
cout<<"
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄ";
delay(2000);
menu();
for(int i=0;i<53;i++)
{
gotoxy(i+28,19);
puts(" ¯Äį");
delay(50);
}
cout<<" If your choice is reservation ,
number to be input is
1";
cout<<" press any key to continue";
getch();
}
//ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄ
// END OF PROGRAMME
//######################################################################
##
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<alloc.h>
#include<dos.h>
void disp(struct node*);
struct node *addbeg(struct node *,int);
void addend(struct node *,int);
void sortlist(struct node*,int);
struct node *addbef(struct node *,int);
void addaft(struct node *,int);
void addbet(struct node *,int,int);
struct node *del(struct node *,int);
struct node *befdel(struct node *,int);
void aftdel(struct node *,int);
void betdel(struct node *,int,int);
void update(struct node *,int);
void search(struct node *,int);
struct node *reverse(struct node *);
struct node{ int n;
struct node *next;
};
void main()
{ char ch,boolc1,boolc2,boolc3,boolc4,boolc5,boolc6,boolc7;
int
i,num,no,addb,adde,befadd,aftadd,fnode,snode,cut,befcut,aftcut,prnode,succ
node,change,find;
struct node *head,*tail,*ptr;
clrscr();
printf("THIS IS A PROGRAM ABOUT LINKED LIST
");
printf("supply no. of elements in the linked list
");
scanf("%d",&num);
head=tail=ptr=NULL;
for(i=0;i<num;i++)
{ printf("supply new node
");
scanf("%d",&no);
ptr=(struct node*)malloc(sizeof(struct node));
if(tail==NULL)
{ head=tail=ptr;
ptr->n=no;
ptr->next=NULL;
}
else
{ tail->next=ptr;
ptr->n=no;
ptr->next=NULL;
tail=ptr;
}
}
disp(head);
printf("node you want to add before
");
scanf("%d",&addb);
if(addb>=0)
{ head=addbeg(head,addb);
printf("Now");
disp(head);
}
else printf("ayou don't! OK
");
printf("node you want to add end
");
scanf("%d",&adde);
if(adde>=0)
{ addend(head,adde);
printf("Now");
disp(head);
}
else printf("ayou don't! OK
");
printf("before which node you want to add?
");
scanf("%d",&befadd);
head=addbef(head,befadd);
printf("Now");
disp(head);
printf("after which node you want to add?
");
scanf("%d",&aftadd);
addaft(head,aftadd);
printf("Now");
disp(head);
printf("between which two nodes you want to add?
");
fflush(stdin);
scanf("%d %d",&fnode,&snode);
addbet(head,fnode,snode);
printf("Now");
disp(head);
printf("want to delete any node? (y/n)
");
fflush(stdin);
scanf("%c",&boolc1);
if(boolc1=='y') { printf("supply node to be deleted
");
scanf("%d",&cut);
head=del(head,cut);
printf("Now");
disp(head);
}
else printf("OK. list remains same
");
printf("want to delete before any node? (y/n)
");
fflush(stdin);
scanf("%c",&boolc2);
if(boolc2=='y') { printf("supply that node
");
scanf("%d",&befcut);
head=befdel(head,befcut);
printf("Now");
disp(head);
}
else printf("OK. list remains same
");
printf("want to delete after any node? (y/n)
");
fflush(stdin);
scanf("%c",&boolc3);
if(boolc3=='y') { printf("supply that node
");
scanf("%d",&aftcut);
aftdel(head,aftcut);
printf("Now");
disp(head);
}
else printf("OK. list remains same
");
printf("want to delete node between any two node? (y/n)
");
fflush(stdin);
scanf("%c",&boolc4);
if(boolc4=='y') { printf("supply those nodes
");
scanf("%d %d",&prnode,&succnode);
betdel(head,prnode,succnode);
printf("Now");
disp(head);
}
else printf("OK. list remains same
");
printf("want to update any node? (y/n)
");
fflush(stdin);
scanf("%c",&boolc5);
if(boolc5=='y') { printf("supply node to be updated
");
scanf("%d",&change);
update(head,change);
printf("Now");
disp(head);
}
else printf("OK. list remains same
");
printf("want to search any node? (y/n)
");
fflush(stdin);
scanf("%c",&boolc6);
if(boolc6=='y') { printf("node to be searched
");
scanf("%d",&find);
search(head,find);
}
else printf("OK. list remains same
");
printf("want to display the list in reverse order? (y/n)
");
fflush(stdin);
scanf("%c",&boolc7);
if(boolc7=='y') { printf("In reverse order");
head=reverse(head);
disp(head);
}
else printf("OK. list remains same
");
printf("wish to sort the list? (y/n)
");
fflush(stdin);
scanf("%c",&ch);
if(ch=='y')
{ sortlist(head,num);
printf("after sorting");
disp(head); }
else{ printf("Finally");
disp(head); }
getch();
}
void disp(struct node *head)
{ struct node *p;
p=head;
printf(" entire linked list is
");
while(p->next!=NULL)
{ printf("%d->",p->n);
p=p->next;
if (p->next==NULL)
printf("%d
",p->n);
}
return;
}
void sortlist(struct node *head,int num)
{ struct node *temp,*q;
int i,j;
q=head;
temp=(struct node *)malloc(sizeof(struct node));
for(i=0;i<num;i++)
for(j=0;j<num-1;j++)
{ while(q->next!=NULL)
{ if((q->n)>(q->next->n))
{ temp->n=q->n;
q->n=q->next->n;
q->next->n=temp->n;
}
q=q->next;
}
if(q->next==NULL && i<num)
q=head;
}
q=head;
return;
}
struct node *addbeg(struct node *head,int addn)
{ struct node *p;
p=(struct node *)malloc(sizeof(struct node));
p->n=addn;
p->next=head;
head=p;
return head;
}
void addend(struct node *head,int addn)
{ struct node *p,*q;
p=(struct node *)malloc(sizeof(struct node));
q=head;
while(q->next!=NULL)
q=q->next;
q->next=p;
p->n=addn;
p->next=NULL;
return;
}
struct node *addbef(struct node *head,int befadd)
{ struct node *p,*q,*r;
int addp;
printf("new node
");
scanf("%d",&addp);
p=(struct node *)malloc(sizeof(struct node));
p->n=addp;
q=r=head;
while(q->n!=befadd)
{ r=q;
q=q->next;
if(q==NULL) break;
}
if(q==NULL) { printf("anode %d not found
",befadd);
delay(1000);
return head;
}
if(q==head) { p->next=q;
head=p;
return head;
}
r->next=p;
p->next=q;
return head;
}
void addaft(struct node *head,int aftadd)
{ struct node *p,*q;
int addp;
printf("new node
");
scanf("%d",&addp);
p=(struct node *)malloc(sizeof(struct node));
p->n=addp;
q=head;
while(q->n!=aftadd)
{ q=q->next;
if(q==NULL) break;
}
if(q==NULL) { printf("anode %d not found
",aftadd);
delay(1000);
return;
}
p->next=q->next;
q->next=p;
return;
}
void addbet(struct node *head,int no1,int no2)
{ struct node *p,*q,*r,*s;
int addp;
// printf("%d %d
",*no1,*no2);
printf("new node
");
scanf("%d",&addp);
p=(struct node *)malloc(sizeof(struct node));
p->n=addp;
r=head;
q=r;
if(q->n!=no1)
{ r=q;
q=q->next;
}
else
{ if (q->next->n!=no2)
{ s=q->next;
while(s!=NULL) { s=s->next;
if(s->n==no2)
{ printf("anodes are not successive
");
delay(1000);
return;
}
}
printf("aillegal node selection
");
delay(1000);
return;
}
else { q=q->next;
r->next=p;
p->next=q;
return;
}
}
while(r->n!=no1 || q->n!=no2)
{ r=q;
q=q->next;
if(q==NULL)
{ printf("aillegal node selection
");
delay(1000);
return;
}
}
r->next=p;
p->next=q;
return;
}
struct node *del(struct node *head,int cut)
{ struct node *p,*q;
p=head;
q=p;
while(p->n!=cut)
{ q=p;
p=p->next;
if(p==NULL) { printf("anode %d not found
",cut);
delay(1000);
return head;
}
}
if(p==head) { head=q->next;
q=head;
free(p);
return head;
}
q->next=p->next;
free(p);
return head;
}
struct node *befdel(struct node *head,int befcut)
{ struct node *p,*q;
p=head;
q=p;
while(p->next->n!=befcut)
{ q=p;
p=p->next;
if(p==NULL) { printf("anode %d not found
",befcut);
delay(1000);
return head;
}
}
if(p==head) { head=q->next;
q=head;
free(p);
return head;
}
q->next=p->next;
free(p);
return head;
}
void aftdel(struct node *head,int aftcut)
{ struct node *p,*q;
p=head;
q=p;
while(q->n!=aftcut)
{ q=p;
p=p->next;
if(p==NULL) { if(q->next==NULL) printf("ano node after node
%d
",aftcut);
else printf("anode %d not found
",aftcut);
delay(1000);
return;
}
}
if(q==head) p=q->next;
q->next=p->next;
free(p);
return;
}
void betdel(struct node *head,int prnode,int succnode)
{ struct node *p,*q,*r,*s;
p=head;
q=p;
if(p->n!=prnode)
{ q=p;
p=p->next;
}
else { r=p->next;
if(r->next->n!=succnode)
{ s=r->next;
while(s!=NULL) { s=s->next;
if(s->n==succnode)
{ printf("amore nodes between those nodes
");
delay(1000);
return;
}
}
printf("aillegal node selection
");
delay(1000);
return;
}
else { q->next=r->next;
free(r);
return;
}
}
while(q->n!=prnode || p->next->n!=succnode)
{ q=p;
p=p->next;
if(p->next==NULL) { printf("aillegal node selection
");
delay(1000);
return;
}
}
q->next=p->next;
free(p);
return;
}
void update(struct node *head,int change)
{ struct node *p;
int upd;
p=head;
printf("updated node
");
scanf("%d",&upd);
while(p->n!=change)
{ p=p->next;
if(p==NULL) { printf("anode %d not found
",change);
delay(1000);
return;
}
}
p->n=upd;
return;
}
void search(struct node *head,int find)
{ struct node *p;
int j=1;
p=head;
while(p->n!=find)
{ p=p->next;
j++;
if(p==NULL) { printf("
SORRY. node %d is not present
",find);
delay(1000);
return;
}
}
printf("aYES! the node %d is present in the %dth
position
",find,j);
delay(1000);
return;
}
struct node *reverse(struct node *head)
{ struct node *t1,*t2;
t1=head->next;
t2=t1->next;
head->next=NULL;
while(t1!=NULL)
{ t1->next=head;
head=t1;
t1=t2;
t2=t2->next;
}
return head;
}
#include<stdio.h>
#include<conio.h>
#define MAX 79
#define ESC 27
void main()
{
char res,r;
int i,k=0,y;
long j=0,l=0,o=0;
textcolor(15);
for(i=0;i<5000;i++)
cprintf(" ");
while(1)
{
clrscr();
printf("Enter Any Number To Be Converted : ");
scanf("%ld",&j);
l=j;
o=l;
k=0;
if(j>2145555550)
{
textcolor(4);
gotoxy(15,5);
cprintf("The Number Is Greater Than
Range");
textcolor(15);
getch();
goto end;
}
else
{
gotoxy(1,6);
printf("Binary Equivalent:-");
y=MAX;
while(j>0)
{
k=j%2;
j=j/2;
gotoxy(y,6);
y--;
printf("%d",k);
}
gotoxy(1,8);
printf("Hexadecimal Equivalent:- ");
y=MAX;
while(l>0)
{
k=l%16;
l=l/16;
gotoxy(y,8);
y--;
if(k<=9)
{
printf("%d",k);
}
if(k==10)
{
printf("A");
}
if(k==11)
{
printf("B");
}
if(k==12)
{
printf("C");
}
if(k==13)
{
printf("D");
}
if(k==14)
{
printf("E");
}
if(k==15)
{
printf("F");
}
}
gotoxy(1,10);
printf("Octal Equivalent:- ");
y=MAX;
while(o>0)
{
k=o%8;
o=o/8;
gotoxy(y,10);
y--;
printf("%d",k);
}
}
gotoxy(15,25);
printf("Press Any Key To Continue , ESC To Exit");
res=getch();
if(res==ESC)
{
break;
}
}
end:
textcolor(7);
for(i=0;i<5000;i++)
cprintf(" ");
clrscr();
}