Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 57d639f

Browse files
ADS Final VIVA
1 parent 790875a commit 57d639f

25 files changed

+1257
-1
lines changed

‎Class.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Nishkarsh 41

‎DoubleLL.cpp

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
#include<iostream>
2+
using namespace std;
3+
class student
4+
{
5+
public:
6+
string rollno;
7+
string sapid;
8+
string name;
9+
string specialization;
10+
student *next;
11+
student *prev;
12+
student()
13+
{
14+
rollno="R171217041";
15+
sapid="500060720";
16+
name="Nishkarsh Raj Khare";
17+
specialization="DevOps";
18+
}
19+
void insert()
20+
{
21+
cout<<"Enter the name of the person"<<endl;
22+
cin>>name;
23+
cout<<"Enter the sapid of the student"<<endl;
24+
cin>>sapid;
25+
cout<<"Enter the rollno of the student"<<endl;
26+
cin>>rollno;
27+
cout<<"Enter the Specialization of the student"<<endl;
28+
cin>>specialization;
29+
}
30+
void show()
31+
{
32+
cout<<"Name of the student is :"<<name<<endl;
33+
cout<<"Roll Number of the student is :"<<rollno<<endl;
34+
cout<<"Sapid of the student is :"<<sapid<<endl;
35+
cout<<"Specialization of the student is :"<<specialization<<endl;
36+
}
37+
};
38+
int main()
39+
{
40+
cout<<"Hello! This is a code of Double Linked List on Student's Data"<<endl;
41+
//Creation of first node
42+
student *node,*ptr,*p,*start;
43+
node=new student;
44+
cout<<"Lets insert the first node data"<<endl;
45+
node->insert();
46+
node->next=NULL;
47+
node->prev=NULL;
48+
cout<<"Lets see the details of first node"<<endl;
49+
node->show();
50+
start=node;
51+
string n,n2;
52+
int flag=0;
53+
int quit=0,choice;
54+
do
55+
{
56+
cout<<"\t\t\t\tOption Menu\n\n"<<endl;
57+
cout<<"1) Insertion at Beginning"<<endl;
58+
cout<<"2) Insertion at End"<<endl;
59+
cout<<"3) Insertion at any point"<<endl;
60+
cout<<"4) Deletion at Beginning"<<endl;
61+
cout<<"5) Deleltion at end"<<endl;
62+
cout<<"6) Deletion at any point"<<endl;
63+
cout<<"7) Traversal of nodes from start"<<endl;
64+
cout<<"8) Traversal of nodes from last"<<endl;
65+
cout<<"9) Quit"<<endl;
66+
cout<<"Enter your choice"<<endl;
67+
cin>>choice;
68+
switch(choice)
69+
{
70+
case 1: cout<<"Insertion at Beginning"<<endl;
71+
ptr=new student;
72+
ptr->insert();
73+
start->prev=ptr;
74+
ptr->next=start;
75+
ptr->prev=NULL;
76+
start=ptr;
77+
break;
78+
case 2: cout<<"Insertion at End"<<endl;
79+
node=new student;
80+
node->insert();
81+
node->next=NULL;
82+
for(ptr=start;ptr->next!=NULL;ptr=ptr->next);
83+
ptr->next=node;
84+
node->prev=ptr;
85+
break;
86+
case 3: cout<<"Insertion at any point"<<endl;
87+
cout<<"Enter the name of the student after which you want to make the insertion"<<endl;
88+
cin>>n;
89+
for(ptr=start;ptr!=NULL;ptr=ptr->next)
90+
{
91+
if(ptr->name==n)
92+
break;
93+
}
94+
node=new student;
95+
node->insert();
96+
p=ptr->next;
97+
node->next=ptr->next;
98+
node->prev=p->prev;
99+
ptr->next=node;
100+
break;
101+
case 4: cout<<"Deletion at beginning"<<endl;
102+
ptr=start;
103+
start=ptr->next;
104+
delete ptr;
105+
break;
106+
case 5: cout<<"Deletion at End"<<endl;
107+
for(ptr=start;ptr->next!=NULL;p=ptr,ptr=ptr->next);
108+
delete ptr;
109+
p->next=NULL;
110+
break;
111+
case 6: cout<<"Deletion anywhere"<<endl;
112+
cout<<"Enter name of the student whose record you want to delete"<<endl;
113+
cin>>n2;
114+
for(ptr=start;ptr->next!=NULL;p=ptr,ptr=ptr->next)
115+
{
116+
if(ptr->name==n2)
117+
{
118+
flag=1;
119+
break;
120+
}
121+
if(flag==1)
122+
{
123+
cout<<"Record Does not exist"<<endl;
124+
}
125+
else
126+
{
127+
p->next=ptr->next;
128+
delete ptr;
129+
}
130+
}
131+
break;
132+
case 7: cout<<"Traversal from start"<<endl;
133+
for(ptr=start;ptr!=NULL;ptr=ptr->next)
134+
ptr->show();
135+
break;
136+
case 8: cout<<"Traversal from the end"<<endl;
137+
for(ptr=start;ptr->next!=NULL;ptr=ptr->next);
138+
for(;ptr!=NULL;ptr=ptr->prev)
139+
{
140+
ptr->show();
141+
}
142+
break;
143+
case 9: quit=1;
144+
break;
145+
default: cout<<"Wrong Choice! Please Try Again"<<endl;
146+
}
147+
}while(quit!=1);
148+
return 0;
149+
}

‎Expt_4_1_1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ int main()
3232
location obj1(10,20),obj2(14,35),obj3;
3333
obj1.show();
3434
obj2.show();
35-
obj3=obj1+obj2+obj30;
35+
obj3=obj1+obj2+obj3;
3636
obj3.show();
3737
/*obj3=obj3+100;
3838
obj3.show();

‎Expt_4_1_1.exe

1.83 MB
Binary file not shown.

‎Independence.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Nishkarsh Raj Khare is the best baaybaaay!!!

‎Nishkarsh.txt

12 Bytes
Binary file not shown.

‎bestgenericfunction.cpp

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#include<cstdlib>
2+
#include<iostream>
3+
using namespace std;
4+
template<typename X>
5+
void sort(X *arr,int size) //generic sort
6+
{
7+
int i,j;
8+
X temp;
9+
for(i=0;i<size;i++)
10+
{
11+
for(j=0;j<size-1;j++)
12+
{
13+
if(arr[j+1]<arr[j])
14+
{
15+
temp=arr[j];
16+
arr[j]=arr[j+1];
17+
arr[j+1]=temp;
18+
}
19+
}
20+
}
21+
}
22+
template<typename Y> //generic insertions
23+
void insert(Y *arr,int size)
24+
{
25+
int i;
26+
cout<<"Lets make the insertions now"<<endl;
27+
for(i=0;i<size;i++)
28+
{
29+
cout<<"Enter the "<<i+1<<" element now"<<endl;
30+
cin>>arr[i];
31+
}
32+
}
33+
template<typename Z> //generic display
34+
void display(Z *arr,int size)
35+
{
36+
int i;
37+
cout<<"Sorted array is now being displayed"<<endl;
38+
for(i=0;i<size;i++)
39+
{
40+
cout<<arr[i]<<endl;
41+
}
42+
}
43+
int main()
44+
{
45+
int quit=0,ch,n;
46+
cout<<"Sorting program in Templates"<<endl;
47+
cout<<"Enter the size of the array you want to sort"<<endl;
48+
cin>>n;
49+
int A[n];
50+
float B[n];
51+
char C[n];
52+
do
53+
{
54+
cout<<"Option Menu"<<endl;
55+
cout<<"1: Int array"<<endl;
56+
cout<<"2: Float array"<<endl;
57+
cout<<"3: Character array"<<endl;
58+
cout<<"4: Quit"<<endl;
59+
cout<<"Enter you choice"<<endl;
60+
cin>>ch;
61+
switch(ch)
62+
/*Note that you cannot declare arrays inside switch*/
63+
{
64+
case 1:
65+
insert(A,n);
66+
sort(A,n);
67+
display(A,n);
68+
break;
69+
case 2:
70+
insert(B,n);
71+
sort(B,n);
72+
display(B,n);
73+
break;
74+
case 3:
75+
insert(C,n);
76+
sort(C,n);
77+
display(C,n);
78+
break;
79+
case 4: quit=1;
80+
break;
81+
default: cout<<"Wrong Choice"<<endl;
82+
}
83+
}while(quit!=1);
84+
return 0;
85+
system("clear");
86+
}

‎binaryclass.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#include<iostream>
2+
#include<fstream>
3+
using namespace std;
4+
class student
5+
{
6+
int roll;
7+
string name;
8+
public:
9+
student()
10+
{
11+
roll=41;
12+
name="Nishkarsh Raj Khare";
13+
}
14+
void insert()
15+
{
16+
cout<<"Lets insert the value"<<endl;
17+
cout<<"Enter the name of the student"<<endl;
18+
getline(cin,name);
19+
cout<<"Enter the roll number of the student"<<endl;
20+
cin>>roll;
21+
}
22+
void show()
23+
{
24+
cout<<"Name of the student is "<<name<<endl;
25+
cout<<"Roll number of the student is "<<roll<<endl;
26+
}
27+
};
28+
int main()
29+
{
30+
cout<<"Binary files with classes"<<endl;
31+
fstream nish1;
32+
nish1.open("classbin.txt",ios::binary|ios::app);
33+
student s1;
34+
s1.insert();
35+
nish1.write((char*)&s1,sizeof(s1));
36+
cout<<"We have written the contents inside the file"<<endl<<"Lets Read it Maaaaaaaaaaaaan"<<endl;
37+
student s2;
38+
nish1.close();
39+
fstream nish2;
40+
int i;
41+
nish2.open("classbin.txt",ios::binary|ios::in);
42+
for(i=0;i<2;i++)
43+
{
44+
nish2.read((char*)&s2,sizeof(s2));
45+
s2.show();
46+
}
47+
cout<<"Goodbye"<<endl;
48+
return 0;
49+
}

‎binaryfile.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#include<iostream>
2+
#include<fstream>
3+
using namespace std;
4+
int main()
5+
{
6+
cout<<"Binary files!"<<endl;
7+
fstream nish; //general declaration of logical name
8+
nish.open("Nishkarsh.txt",ios::binary|ios::out); //explicitly open as out mode to write to the file
9+
//even text files can be written as binary files only defined by the write and read functions
10+
int ch,quit=0,num,k=-1;
11+
do
12+
{
13+
cout<<"1: Enter a number"<<endl;
14+
cout<<"2: Quit"<<endl;
15+
cout<<"Enter your choice"<<endl;
16+
cin>>ch;
17+
switch(ch)
18+
{
19+
case 1:
20+
cout<<"Enter the number you want to enter to the file"<<endl;
21+
cin>>num;
22+
nish.write((char*)&num,sizeof(num));
23+
break;
24+
case 2: quit=1;
25+
break;
26+
}
27+
k++;
28+
}while(quit!=1);
29+
nish.close();
30+
cout<<"Writing Over! Lets see what you have inserted"<<endl;
31+
fstream nish1;
32+
nish1.open("Nishkarsh.txt",ios::binary|ios::in);
33+
cout<<"There were "<<k<<" insertions"<<endl;
34+
int A[k];
35+
int i;
36+
for(i=0;i<k;i++)
37+
{
38+
nish1.read((char*)&A[i],sizeof(int));
39+
}
40+
for(i=0;i<k;i++)
41+
{
42+
cout<<"The "<<i+1<<" insertion is "<<A[i]<<endl;
43+
}
44+
return 0;
45+
}
46+
47+
48+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /