├── .DS_Store ├── AB ├── alto-bas.exe ├── alto-bas.obj ├── Alto-Basso.txt └── alto-bas.cpp ├── Leap Year ├── main.exe ├── main.obj ├── tcwdef.csm ├── noname00.exe ├── noname00.obj ├── leapyear.cpp ├── main.bak └── main.cpp ├── Swap by passing pointers └── PSWAP.CPP ├── Data File Search └── filesear.cpp ├── Copy File to Another └── COPY.CPP ├── Word Occurence └── word occurence.cpp ├── Selection Sort └── selsort.cpp ├── queue.CPP ├── stack.CPP ├── linkedlist.CPP ├── Bookshop └── bookshop.cpp ├── 1D Operations └── 1d.cpp └── PRAC.CPP /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karan/reallyreallyoldcode/master/.DS_Store -------------------------------------------------------------------------------- /AB/alto-bas.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karan/reallyreallyoldcode/master/AB/alto-bas.exe -------------------------------------------------------------------------------- /AB/alto-bas.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karan/reallyreallyoldcode/master/AB/alto-bas.obj -------------------------------------------------------------------------------- /Leap Year/main.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karan/reallyreallyoldcode/master/Leap Year/main.exe -------------------------------------------------------------------------------- /Leap Year/main.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karan/reallyreallyoldcode/master/Leap Year/main.obj -------------------------------------------------------------------------------- /Leap Year/tcwdef.csm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karan/reallyreallyoldcode/master/Leap Year/tcwdef.csm -------------------------------------------------------------------------------- /Leap Year/noname00.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karan/reallyreallyoldcode/master/Leap Year/noname00.exe -------------------------------------------------------------------------------- /Leap Year/noname00.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karan/reallyreallyoldcode/master/Leap Year/noname00.obj -------------------------------------------------------------------------------- /Swap by passing pointers/PSWAP.CPP: -------------------------------------------------------------------------------- 1 | //Swap nos by passing pointers 2 | 3 | #include 4 | #include 5 | 6 | void swap(int *x, int *y) 7 | { 8 | int temp; 9 | temp=*x; 10 | *x=*y; 11 | *y=temp; 12 | } 13 | 14 | void main() 15 | { 16 | clrscr(); 17 | int a,b; 18 | cout<<"Enter number 1 (a)"; cin>>a; 19 | cout<<"Enter number 2 (b)"; cin>>b; 20 | cout<>rn; 16 | 17 | ifstream file("file.dat", ios::in); 18 | 19 | while(!file.eof()) 20 | { 21 | file.read((char *)&s1, sizeof(s1)); 22 | if(s1.rollno==rn) 23 | cout< 2 | #include 3 | 4 | void main() 5 | { 6 | clrscr(); 7 | char date[10]; 8 | int year[4], yr; 9 | 10 | cout<<"Enter Date (dd-mm-yyyy)"; cin>>date; 11 | 12 | year[0]=date[6]-48; 13 | year[1]=date[7]-48; 14 | year[2]=date[8]-48; 15 | year[3]=date[9]-48; 16 | 17 | yr=(year[0]*1000)+(year[1]*100)+(year[2]*10)+year[3]; 18 | 19 | cout<<"\n\nYear is "< 4 | #include 5 | #include 6 | 7 | void main() 8 | { 9 | clrscr(); 10 | char a[20], b[20], text[100]; 11 | cout<<"Enter name of original file"; 12 | gets(a); 13 | cout<<"Enter name of new file"; 14 | gets(b); 15 | 16 | fstream file1(a, ios::in); 17 | fstream file2(b, ios::out); 18 | 19 | while(!file1.eof()) 20 | { 21 | for(int i=0;i<100;i++) 22 | file1.get(text[i]); 23 | } 24 | 25 | puts(text); 26 | 27 | 28 | for(int i=0;i<100;i++) 29 | file2.put(text[i]); 30 | 31 | cout<<"Done!!"; 32 | getch(); 33 | } 34 | -------------------------------------------------------------------------------- /Word Occurence/word occurence.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | void main() 7 | { 8 | clrscr(); 9 | char word[10],w[10], text[1000]; 10 | int count=0; 11 | fstream file; 12 | 13 | file.open("File.txt", ios::in|ios::out); 14 | 15 | cout<<"Enter text\n"; 16 | gets(text); 17 | for(int i=0;i>n; 38 | 39 | cout<<"Enter array elements\n"; 40 | for(int i=0;i>ar[i]; 42 | 43 | sort(ar, n); 44 | 45 | getch(); 46 | } -------------------------------------------------------------------------------- /Leap Year/main.bak: -------------------------------------------------------------------------------- 1 | // DiaVolo 2 | 3 | #include 4 | #include 5 | #include //for exit(); 6 | 7 | void main() 8 | { 9 | clrscr(); 10 | 11 | int choice; 12 | 13 | cout<<"\n\n"; 14 | cout<<"##############################\n"; 15 | cout<<"# Welcome to DiaVolo\n"; 16 | cout<<"# The mini-game pack contains 2 games:\n"; 17 | cout<<"# 1. U Guess\n"; 18 | cout<<"# 2. I Guess\n"; 19 | cout<<"##############################\n"; 20 | cout<<"\nEnter 1 or 2 to play the game, or 3 to exit."; 21 | cout<<"\nYour choice: "; 22 | cin>>choice; 23 | 24 | switch(choice) 25 | { 26 | case 1: //uguess(); //Call U Guess 27 | break; 28 | case 2: //iguess(); //Call I Guess 29 | break; 30 | case 3: exit(0); //Exit game 31 | default: cout<<"Enter the correct choice... "; //For invalid input 32 | } 33 | 34 | getch(); 35 | } 36 | -------------------------------------------------------------------------------- /queue.CPP: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | class que 5 | { 6 | int q[100], f, r; 7 | int overflow(); 8 | int underflow(); 9 | public: 10 | que(){f=-1;r=-1;} 11 | ~que(){} 12 | void insert(int); 13 | int del(); 14 | void disp(); 15 | }q1; 16 | 17 | void que::insert(int val) 18 | { 19 | if(r==-1) 20 | {f=r=0; 21 | q[r]=val;} 22 | else 23 | {r++; 24 | q[r]=val;} 25 | cout<<"Insertion Done"<>ch; 52 | 53 | switch(ch) 54 | { case 1: cout<<"val: "; cin>>val; 55 | q1.insert(val); 56 | break; 57 | case 2: val=q1.del(); 58 | cout<>op; 64 | }while(op=='y'); 65 | } -------------------------------------------------------------------------------- /Leap Year/main.cpp: -------------------------------------------------------------------------------- 1 | // DiaVolo 2 | 3 | #include 4 | #include 5 | #include //for exit() 6 | //#include //Let life be colourful 7 | //#include 8 | #include 9 | 10 | void main() 11 | { 12 | clrscr(); 13 | 14 | int choice; 15 | 16 | cout<<"\n\n"; 17 | cout<<"##############################\n"; 18 | cout<<"# Welcome to DiaVolo\n"; 19 | cout<<"# The mini-game pack contains 2 games:\n"; 20 | cout<<"# 1. U Guess\n"; 21 | cout<<"# 2. I Guess\n"; 22 | cout<<"##############################\n"; 23 | cout<<"\nEnter 1 or 2 to play the game, or 3 to exit."; 24 | cout<<"\nYour choice: "; 25 | cin>>choice; 26 | 27 | switch(choice) 28 | { 29 | case 1: cout<<"\n\nWelcome to U Guess.\nI will pick a number between 0 and 100.\n"; 30 | cout<<"You must try to guess it within 7 guesses.!"; 31 | break; 32 | 33 | case 2: cout<<"\n\nWelcome to I Guess.\nThis is an amazing game.\n"; 34 | cout<<"You must choose a number from the following.!"; 35 | break; 36 | 37 | case 3: exit(0); //Exit game 38 | break; 39 | 40 | default: cout<<"Enter the correct choice... "; //For invalid input 41 | } 42 | 43 | getch(); 44 | } 45 | -------------------------------------------------------------------------------- /stack.CPP: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | class stack 5 | { 6 | int st[100], top; 7 | public: 8 | stack(){top=-1;} 9 | ~stack(){} 10 | int underflow(); 11 | int overflow(); 12 | void insert(int); 13 | int del(); 14 | void disp(); 15 | }s; 16 | 17 | int stack::underflow() 18 | { 19 | if(top==0) 20 | return 1; 21 | else 22 | return 0; 23 | } 24 | 25 | int stack::overflow() 26 | { 27 | if(top==99) 28 | return 1; 29 | else 30 | return 0; 31 | } 32 | 33 | void stack::insert(int val) 34 | { 35 | if(!overflow()) 36 | { 37 | top++; 38 | st[top]=val; 39 | cout<<"Value Inserted!"; 40 | } 41 | } 42 | 43 | int stack::del() 44 | { 45 | int val; 46 | if(!underflow()) 47 | { 48 | val=st[top]; 49 | top--; 50 | } 51 | return val; 52 | } 53 | 54 | void stack::disp() 55 | { 56 | cout<<"Stack is: \n"; 57 | for(int i=0; i<=top; i++) 58 | cout<"; 59 | } 60 | 61 | void main() 62 | { 63 | clrscr(); 64 | int ch, val; 65 | char op; 66 | 67 | do{ 68 | cout<<"1. Insert\n2. Delete\n3. Display\n"; 69 | cin>>ch; 70 | 71 | switch(ch) 72 | { 73 | case 1: cout<<"Val: "; cin>>val; 74 | s.insert(val); 75 | break; 76 | case 2: val=s.del(); 77 | cout<>op; 83 | }while(op=='y'); 84 | } -------------------------------------------------------------------------------- /linkedlist.CPP: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct node 5 | { 6 | int data; 7 | node *next; 8 | }; 9 | 10 | class stack 11 | { 12 | node *top; 13 | int underflow(); 14 | public: 15 | stack(){top=NULL;} 16 | ~stack(){} 17 | void push(int); 18 | int pop(); 19 | void disp(); 20 | }s; 21 | 22 | int stack::underflow() 23 | { 24 | if(top==NULL) 25 | return 1; 26 | else 27 | return 0; 28 | } 29 | 30 | void stack::push(int val) 31 | { 32 | node *p=NULL; 33 | p=new node; 34 | p->next=top; 35 | p->data=val; 36 | top=p; 37 | } 38 | 39 | int stack::pop() 40 | { 41 | int val; 42 | node *p=NULL; 43 | if(!underflow()) 44 | { 45 | p=top; 46 | top=top->next; 47 | p->next=NULL; 48 | val=p->data; 49 | } 50 | return val; 51 | } 52 | 53 | void stack::disp() 54 | { 55 | node *p; 56 | p=top; 57 | while(p!=NULL) 58 | { 59 | cout<data<<"->"; 60 | p=p->next; 61 | } 62 | } 63 | 64 | void main() 65 | { 66 | clrscr(); 67 | int ch, val; 68 | char op; 69 | 70 | do{ 71 | cout<<"1. Push\n2. Pop\n3. Display\n"; 72 | cin>>ch; 73 | 74 | switch(ch) 75 | { 76 | case 1: cout<<"Val: "; cin>>val; 77 | s.push(val); 78 | break; 79 | case 2: val=s.pop(); 80 | cout<>op; 86 | }while(op=='y'); 87 | } -------------------------------------------------------------------------------- /AB/Alto-Basso.txt: -------------------------------------------------------------------------------- 1 | #include #include #include const int totchan=7; void main() { int number; //the computer's random number int guess; //the user's guess int chances=0,score=0,chanscor; //chanscor stores score for 1 successful chance. char ans; do { clrscr(); chances=score=0; cout<<"#############################################\n"; cout<<"#\n"; cout<<"# Welcome to the Alto-Basso.\n"; cout<<"# I will pick a random number from 0 to 100.\n"; cout<<"# You must try to guess the number.\n"; cout<<"#\n"; cout<<"#############################################\n"; randomize(); number=(int)(rand()%10); //random number stored in mumber chanscor=100/totchan; //score for each successful chance do { cout<<"\nWhat is your guess? (0 to 100) "; cin>>guess; if((guess<0)||(guess>100)) { cout<<"Sorry, but your guess "< number) { cout<>ans; }while(ans=='y' || ans=='Y'); } -------------------------------------------------------------------------------- /Bookshop/bookshop.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | class bookshop 7 | { 8 | public: 9 | char author[30], title[50], publisher[50]; 10 | int price, stockpos; 11 | void inputbooks(); 12 | void issuebook(int); 13 | }b[100]; 14 | 15 | void bookshop::inputbooks() 16 | { 17 | cout<<"Title: "; gets(title); 18 | cout<<"Author: "; gets(author); 19 | cout<<"Publisher: "; gets(publisher); 20 | cout<<"Price: "; cin>>price; 21 | cout<<"Stock: "; cin>>stockpos; 22 | cout<>nobooks; 45 | cout<>issue; 66 | b[i].issuebook(issue); 67 | } 68 | else 69 | cout<<"Sorry! The book you entered in not in out database!"<>ch; 73 | }while(ch=='y'||ch=='Y'); 74 | 75 | getch(); 76 | } 77 | -------------------------------------------------------------------------------- /AB/alto-bas.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | const int totchan=7; 6 | void main() 7 | { 8 | int number; //the computer's random number 9 | int guess; //the user's guess 10 | int chances=0,score=0,chanscor; //chanscor stores score for 1 successful chance. 11 | char ans; 12 | do 13 | { 14 | clrscr(); 15 | chances=score=0; 16 | 17 | cout<<"#############################################\n"; 18 | cout<<"#\n"; 19 | cout<<"# Welcome to the Alto-Basso.\n"; 20 | cout<<"# I will pick a random number from 0 to 100.\n"; 21 | cout<<"# You must try to guess the number.\n"; 22 | cout<<"#\n"; 23 | cout<<"#############################################\n"; 24 | 25 | randomize(); 26 | number=(int)(rand()%10); //random number stored in mumber 27 | chanscor=100/totchan; //score for each successful chance 28 | 29 | do 30 | { 31 | cout<<"\nWhat is your guess? (0 to 100) "; 32 | cin>>guess; 33 | if((guess<0)||(guess>100)) 34 | { 35 | cout<<"Sorry, but your guess "< number) 42 | { 43 | cout<>ans; 65 | }while(ans=='y' || ans=='Y'); 66 | } -------------------------------------------------------------------------------- /1D Operations/1d.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | class array 5 | { 6 | public: 7 | void insert(int [], int, int); 8 | void del(int [], int, int); 9 | void app(int [], int, int [], int); 10 | void merge(int [], int, int [], int); 11 | }a1; 12 | 13 | void array::insert(int a[], int n1, int ele) 14 | { 15 | n1++; 16 | a[n1-1]=ele; 17 | cout<<"Done\n"; 18 | cout<<"New List:"; 19 | for(int i=0;i=0;) 58 | { 59 | if(a[x]<=b[y]) 60 | c[z++]=a[x++]; 61 | else 62 | c[z++]=b[y--]; 63 | } 64 | 65 | if(x=0) 73 | c[z++]=b[y--]; 74 | } 75 | 76 | cout<<"Done\n"; 77 | cout<<"New List:"; 78 | for(int i=0;i>n1; 91 | cout<<"Enter Array Elements: "; 92 | for(int i=0;i>a[i]; 94 | 95 | do 96 | { 97 | cout<<"\n1. Insert at last"; 98 | cout<<"\n2. Delete an element"; 99 | cout<<"\n3. Append a list"; 100 | cout<<"\n4. Merge two lists"; 101 | cout<>ch; 103 | 104 | switch(ch) 105 | { 106 | case 1: cout<<"Enter element to insert: "; 107 | cin>>ele; 108 | a1.insert(a,n1,ele); 109 | break; 110 | case 2: cout<<"Enter element to delete: "; 111 | cin>>ele; 112 | a1.del(a,n1,ele); 113 | break; 114 | case 3: cout<<"Enter size of list 2: "; 115 | cin>>n2; 116 | cout<<"Enter elements: "; 117 | {for(int l=0;l>b[l];} 119 | a1.app(a,n1,b,n2); 120 | break; 121 | case 4: cout<<"Enter size of list 2: "; 122 | cin>>n2; 123 | cout<<"Enter elements: "; 124 | {for(int p=0;p>b[p];} 126 | a1.merge(a,n1,b,n2); 127 | break; 128 | default: cout<<"Invalid Entry\n"; 129 | break; 130 | } 131 | cout<<"Continue?"; 132 | cin>>op; 133 | }while(op=='y'||op=='Y'); 134 | 135 | getch(); 136 | } -------------------------------------------------------------------------------- /PRAC.CPP: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | class student 8 | { 9 | char name[10]; 10 | int rollno; 11 | public: 12 | void create(); 13 | void append(); 14 | void del(); 15 | void disp(); 16 | void modify(); 17 | }s; 18 | 19 | void student::create() 20 | { 21 | fstream file; 22 | char fname[12]; 23 | cout<<"Enter filename with extension: "; gets(fname); 24 | file.open(fname, ios::out|ios::binary); 25 | cout<<"Student Name: "; gets(name); 26 | cout<<"Roll No: "; cin>>rollno; 27 | 28 | file.write((char *)this, sizeof(student)); 29 | cout<<"File creation done!"; 30 | file.close(); 31 | } 32 | 33 | void student::append() 34 | { 35 | fstream file; 36 | char fname[12]; 37 | cout<<"Enter filename with extension: "; gets(fname); 38 | file.open(fname, ios::app|ios::binary); 39 | cout<<"Student Name: "; gets(name); 40 | cout<<"Roll No: "; cin>>rollno; 41 | 42 | file.write((char *)this, sizeof(s)); 43 | cout<<"Appending Done!"; 44 | file.close(); 45 | } 46 | 47 | void student::del() 48 | { 49 | fstream file, tmp; 50 | char fname[12]; 51 | int rn; 52 | cout<<"Enter filename with entension: "; gets(fname); 53 | file.open(fname, ios::in|ios::binary); 54 | tmp.open("temp.dat", ios::out|ios::binary); 55 | 56 | cout<<"Roll No of student to be deleted: "; cin>>rn; 57 | file.read((char *)this, sizeof(s)); 58 | while(!file.eof()) 59 | { 60 | if(s.rollno!=rn) 61 | tmp.write((char *)this, sizeof(s)); 62 | file.read((char *)this, sizeof(s)); 63 | } 64 | 65 | remove(fname); 66 | rename("temp.dat", fname); 67 | cout<<"Deletion done!"; 68 | tmp.close(); 69 | file.close(); 70 | } 71 | 72 | void student::disp() 73 | { 74 | fstream file; 75 | char fname[12]; 76 | cout<<"Enter filename with entension: "; gets(fname); 77 | file.open(fname, ios::in|ios::binary); 78 | file.read((char *)this, sizeof(s)); 79 | while(!file.eof()) 80 | { 81 | cout<<"Name: "<>rollno; 107 | file.write((char *)this, sizeof(student)); 108 | cout<<"Modifying Done!"; 109 | flag=1; 110 | } 111 | file.read((char *)this, sizeof(student)); 112 | } 113 | file.close(); 114 | } 115 | 116 | void main() 117 | { 118 | clrscr(); 119 | 120 | char ch; 121 | int op; 122 | 123 | do{ 124 | clrscr(); 125 | 126 | cout<<"### MAIN MENU ###\n"; 127 | cout<<"# 1. Create a file\n"; 128 | cout<<"# 2. Append to existing file\n"; 129 | cout<<"# 3. Delete existing record\n"; 130 | cout<<"# 4. Display contents of file\n"; 131 | cout<<"# 5. Modify a file\n"; 132 | cout<<"# 6. Exit\n"; 133 | cout<<"#################\n\n"; 134 | 135 | cout<<"Enter choice: "; cin>>op; 136 | 137 | switch(op) 138 | { 139 | case 1: s.create(); 140 | break; 141 | case 2: s.append(); 142 | break; 143 | case 3: s.del(); 144 | break; 145 | case 4: s.disp(); 146 | break; 147 | case 5: s.modify(); 148 | break; 149 | case 6: exit(0); 150 | break; 151 | default: cout<<"Invalid Entry!"; 152 | break; 153 | } 154 | 155 | cout<<"\nContinue? "; cin>>ch; 156 | }while(ch=='y'||ch=='Y'); 157 | 158 | getch(); 159 | } --------------------------------------------------------------------------------