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 7074f61

Browse files
Nish from linux
2 parents 620e4fe + 068b4e7 commit 7074f61

12 files changed

+606
-0
lines changed

‎Expt_1_1.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include<iostream>
2+
using namespace std;
3+
class lenght1 //unlike main its not allowed to make variable declarations within member functions/
4+
{
5+
float lenght;
6+
float l1;
7+
public:
8+
void setlenght(float l)
9+
{
10+
lenght=l;
11+
}
12+
void convert()
13+
{
14+
if(lenght>12)
15+
{
16+
l1=(int)lenght/12;
17+
lenght=int(lenght)%12; //note that float does not allow mod function to work upon
18+
}
19+
cout<<"Lenght is "<<l1<<" feets and "<<lenght<<" inches"<<endl;
20+
}
21+
};
22+
int main()
23+
{
24+
cout<<"Program to convert Lenght from inches to foot+inches"<<endl;
25+
float l;
26+
cout<<"Enter lenght in inches"<<endl;
27+
cin>>l;
28+
lenght1 obj;
29+
obj.setlenght(l);
30+
obj.convert();
31+
cout<<endl;
32+
return 0;
33+
}

‎Expt_1_2.cpp

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#include<iostream>
2+
using namespace std;
3+
class Queue
4+
{
5+
public: //all public needed to access outside in main
6+
string name;
7+
int roll_number;
8+
double total_marks;
9+
Queue *next;
10+
void show()
11+
{
12+
cout<<endl;
13+
cout<<"Name of the person is "<<name<<endl<<"Roll number of the person is "<<roll_number<<endl<<"Total marks of the person are "<<total_marks<<endl;
14+
}
15+
}*rear,*front,*node,*ptr,*p;
16+
int main()
17+
{
18+
int quit=0;
19+
cout<<"Hello! This is a program to demonstrate Queue implementation using Classes and Objects"<<endl;
20+
node=new Queue;
21+
cout<<"Enter the name of this person"<<endl;
22+
cin>>node->name;
23+
cout<<"Enter the roll number of this person"<<endl;
24+
cin>>node->roll_number;
25+
cout<<"Enter the total marks of this person"<<endl;
26+
cin>>node->total_marks;
27+
node->next=NULL;
28+
front=node;
29+
rear=node;
30+
node->show();
31+
cout<<endl;
32+
cout<<"Let the party begins"<<endl;
33+
do
34+
{
35+
cout<<"\t\t\t\tOption Menu"<<endl;
36+
cout<<"1) Insert"<<endl;
37+
cout<<"2) Delete"<<endl;
38+
cout<<"3) Show"<<endl;
39+
cout<<"4) Exit"<<endl;
40+
int ch;
41+
cout<<"Enter your choice"<<endl;
42+
cin>>ch;
43+
switch(ch)
44+
{
45+
case 1: cout<<"Insertion at end"<<endl;
46+
p=new Queue;
47+
cout<<"Enter the name of this person"<<endl;
48+
cin>>p->name;
49+
cout<<"Enter the roll number of this person"<<endl;
50+
cin>>p->roll_number;
51+
cout<<"Enter the total marks of this person"<<endl;
52+
cin>>p->total_marks;
53+
rear->next=p;
54+
p->next=NULL;
55+
rear=p;
56+
break;
57+
case 2: cout<<"Deletion at beginning"<<endl;
58+
cout<<"Object to be deleted is"<<endl;
59+
front->show();
60+
ptr=front;
61+
front=front->next;
62+
delete ptr;
63+
break;
64+
case 3: cout<<"Traversal"<<endl;
65+
for(ptr=front;ptr!=NULL;ptr=ptr->next)
66+
{
67+
int i=1;
68+
cout<<"The "<<i++<<" Record is of";
69+
ptr->show();
70+
}
71+
break;
72+
case 4: quit=1;
73+
break;
74+
default: cout<<"Wrong Choice! Try again"<<endl;
75+
}
76+
}while(quit!=1);
77+
return 0;
78+
}

‎Expt_2_1_1.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include<iostream>
2+
using namespace std;
3+
class lenght1 //unlike main its not allowed to make variable declarations within member functions/
4+
{
5+
float lenght;
6+
float l1;
7+
public:
8+
lenght1()
9+
{
10+
lenght=100;
11+
l1=50;
12+
}
13+
~lenght1()
14+
{
15+
cout<<"Object Destroyed"<<endl;
16+
}
17+
void setlenght(float l)
18+
{
19+
lenght=l;
20+
}
21+
void convert()
22+
{
23+
if(lenght>12)
24+
{
25+
l1=(int)lenght/12;
26+
lenght=int(lenght)%12; //note that float does not allow mod function to work upon
27+
}
28+
cout<<"Lenght is "<<l1<<" feets and "<<lenght<<" inches"<<endl;
29+
}
30+
};
31+
int main()
32+
{
33+
cout<<"Program to convert Lenght from inches to foot+inches"<<endl;
34+
float l;
35+
cout<<"Enter lenght in inches"<<endl;
36+
cin>>l;
37+
lenght1 obj;
38+
obj.setlenght(l);
39+
obj.convert();
40+
cout<<endl;
41+
return 0;
42+
}

‎Expt_2_1_2.cpp

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#include<iostream>
2+
using namespace std;
3+
class Queue
4+
{
5+
public: //all public needed to access outside in main
6+
string name;
7+
int roll_number;
8+
double total_marks;
9+
Queue *next;
10+
Queue()
11+
{
12+
name="Nishkarsh";
13+
roll_number=41;
14+
total_marks=256.60;
15+
}
16+
~Queue()
17+
{
18+
cout<<"Object Destroyed"<<endl;
19+
}
20+
void show()
21+
{
22+
cout<<endl;
23+
cout<<"Name of the person is "<<name<<endl<<"Roll number of the person is "<<roll_number<<endl<<"Total marks of the person are "<<total_marks<<endl;
24+
}
25+
}*rear,*front,*node,*ptr,*p;
26+
int main()
27+
{
28+
int quit=0;
29+
cout<<"Hello! This is a program to demonstrate Queue implementation using Classes and Objects"<<endl;
30+
node=new Queue;
31+
cout<<"Enter the name of this person"<<endl;
32+
cin>>node->name;
33+
cout<<"Enter the roll number of this person"<<endl;
34+
cin>>node->roll_number;
35+
cout<<"Enter the total marks of this person"<<endl;
36+
cin>>node->total_marks;
37+
node->next=NULL;
38+
front=node;
39+
rear=node;
40+
node->show();
41+
cout<<endl;
42+
cout<<"Let the party begins"<<endl;
43+
do
44+
{
45+
cout<<"\t\t\t\tOption Menu"<<endl;
46+
cout<<"1) Insert"<<endl;
47+
cout<<"2) Delete"<<endl;
48+
cout<<"3) Show"<<endl;
49+
cout<<"4) Exit"<<endl;
50+
int ch;
51+
cout<<"Enter your choice"<<endl;
52+
cin>>ch;
53+
switch(ch)
54+
{
55+
case 1: cout<<"Insertion at end"<<endl;
56+
p=new Queue;
57+
cout<<"Enter the name of this person"<<endl;
58+
cin>>p->name;
59+
cout<<"Enter the roll number of this person"<<endl;
60+
cin>>p->roll_number;
61+
cout<<"Enter the total marks of this person"<<endl;
62+
cin>>p->total_marks;
63+
rear->next=p;
64+
p->next=NULL;
65+
rear=p;
66+
break;
67+
case 2: cout<<"Deletion at beginning"<<endl;
68+
cout<<"Object to be deleted is"<<endl;
69+
front->show();
70+
ptr=front;
71+
front=front->next;
72+
delete ptr;
73+
break;
74+
case 3: cout<<"Traversal"<<endl;
75+
for(ptr=front;ptr!=NULL;ptr=ptr->next)
76+
{
77+
int i=1;
78+
cout<<"The "<<i++<<" Record is of";
79+
ptr->show();
80+
}
81+
break;
82+
case 4: quit=1;
83+
break;
84+
default: cout<<"Wrong Choice! Try again"<<endl;
85+
}
86+
}while(quit!=1);
87+
return 0;
88+
}

‎Expt_2_2.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#include<iostream>
2+
using namespace std;
3+
class WWE
4+
{
5+
string name;
6+
float salary;
7+
string nickname;
8+
public:
9+
WWE()
10+
{
11+
name="Seth Rollins";
12+
salary=2000000;
13+
nickname="The Architect";
14+
}
15+
~WWE()
16+
{
17+
cout<<"Object Destroyed"<<endl;
18+
}
19+
WWE(string n,float s,string nn)
20+
{
21+
name=n;
22+
salary=s;
23+
nickname=nn;
24+
}
25+
WWE(WWE &x)
26+
{
27+
name=x.name;
28+
nickname=x.name;
29+
salary=x.salary;
30+
}
31+
void show()
32+
{
33+
cout<<"Name is "<<name<<endl<<"Salary is "<<salary<<endl<<"Nickname is "<<nickname<<endl;
34+
}
35+
};
36+
int main()
37+
{
38+
cout<<"WWE class try out";
39+
WWE a;
40+
a.show();
41+
WWE b("AJ Styles",256643532,"Phenomenal");
42+
b.show();
43+
WWE c=b;
44+
c.show();
45+
return 0;
46+
}
47+

‎Expt_2_3.cpp

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#include<iostream>
2+
using namespace std;
3+
class Stack
4+
{
5+
public: //all public needed to access outside in main
6+
string name;
7+
int roll_number;
8+
double total_marks;
9+
Stack *next;
10+
void show()
11+
{
12+
cout<<endl;
13+
cout<<"Name of the person is "<<name<<endl<<"Roll number of the person is "<<roll_number<<endl<<"Total marks of the person are "<<total_marks<<endl;
14+
}
15+
}*top,*node,*ptr,*p;
16+
int main()
17+
{
18+
int quit=0;
19+
cout<<"Hello! This is a program to demonstrate Stack implementation using Classes and Objects"<<endl;
20+
node=new Stack;
21+
cout<<"Enter the name of this person"<<endl;
22+
cin>>node->name;
23+
cout<<"Enter the roll number of this person"<<endl;
24+
cin>>node->roll_number;
25+
cout<<"Enter the total marks of this person"<<endl;
26+
cin>>node->total_marks;
27+
node->next=NULL;
28+
top=node;
29+
node->show();
30+
cout<<endl;
31+
cout<<"Let the party begins"<<endl;
32+
do
33+
{
34+
cout<<"\t\t\t\tOption Menu"<<endl;
35+
cout<<"1) Insert"<<endl;
36+
cout<<"2) Delete"<<endl;
37+
cout<<"3) Show"<<endl;
38+
cout<<"4) Exit"<<endl;
39+
int ch;
40+
cout<<"Enter your choice"<<endl;
41+
cin>>ch;
42+
switch(ch)
43+
{
44+
case 1: cout<<"Insertion at end"<<endl;
45+
p=new Stack;
46+
cout<<"Enter the name of this person"<<endl;
47+
cin>>p->name;
48+
cout<<"Enter the roll number of this person"<<endl;
49+
cin>>p->roll_number;
50+
cout<<"Enter the total marks of this person"<<endl;
51+
cin>>p->total_marks;
52+
p->next=top;
53+
top=p;
54+
break;
55+
case 2: cout<<"Deletion at End"<<endl;
56+
cout<<"Object to be deleted is"<<endl;
57+
ptr=top;
58+
ptr->show();
59+
top=top->next;
60+
delete ptr;
61+
break;
62+
case 3: cout<<"Traversal"<<endl;
63+
for(ptr=top;ptr!=NULL;ptr=ptr->next)
64+
{
65+
int i=1;
66+
cout<<"The "<<i++<<" Record is of";
67+
ptr->show();
68+
}
69+
break;
70+
case 4: quit=1;
71+
break;
72+
default: cout<<"Wrong Choice! Try again"<<endl;
73+
}
74+
}while(quit!=1);
75+
return 0;
76+
}

‎class.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include<stdio.h>
2+
class employee
3+
{
4+
int emp_id;
5+
string emp_name[20];
6+
public:
7+
void read(int a,string n)
8+
{
9+
emp_id=a;
10+
emp_name=n;
11+
}
12+
friend void show(employee E);
13+
};
14+
void show(employee E)
15+
{
16+
cout<<"Name of the employee is "<<emp_name<<endl<<"ID of the employee is "<<emp_id;
17+
}
18+
int main()
19+
{
20+
employee E;
21+
E.read(23402,"Nishkarsh Raj Khare");
22+
show(E);
23+
return 0;
24+
}

0 commit comments

Comments
(0)

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