0% found this document useful (0 votes)
15 views

mansi

Uploaded by

Kunal Puri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

mansi

Uploaded by

Kunal Puri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

NAME:MANSI ASHOK GAVHALE

COLLAGE : SINHGAD COLLAGE OF ENGINEERING

CLASS:SE1(BATCH D)

SUBJECT:OOP

ROLL NO:205A065

*************************************ASSIGNMENT NO 1**************************

#include<iostream> using

namespace std;

class Complex { public:

float x;

float y;

Complex()

x = 0;

y = 0;

friend istream& operator>>(istream&, Complex&);

friend ostream& operator<<(ostream&, const Complex&);

Complex operator+(const Complex&);

Complex operator*(const Complex&);

};
Complex Complex::operator+(const Complex& c)

Complex add;

add.x = x + c.x;

add.y = y + c.y;

return add;

Complex Complex::operator*(const Complex& c)

Complex mul;

mul.x = (x * c.x) - (y * c.y);

mul.y = (y * c.x) + (x * c.y);

return mul;

istream& operator>>(istream& in, Complex& t)

cout << "\n Enter the Real Part: ";

in >> t.x;

cout << " Enter the Imaginary Part: ";

in >> t.y;

return in;

ostream& operator<<(ostream& out, const Complex& t)

out << t.x; if (t.y >= 0)

out << " + " << t.y << "i";

else out << " - " << -t.y

<< "i"; return out;


}

int main()

Complex c1, c2, c3, c4; cout << "\n

Default Constructor: "; cout << c1;

cout << "\n Enter 1st complex number: ";

cin>>c1;

cout<<"\n Enter 2nd complex number:";

cin>>c2;

cout<<"\n 1st Complex Number:"<<c1; cout<<"\n 2nd

Complex number:"<<c2; c3=c1+c2; cout<<"\n Addition

of two complex number:"<<c3; c4=c1*c2; cout<<"\n

Multiplication of two complex number:"<<c4; return 0;

}
********************ASSIGNMENT NO 2****************************
Name: MANSI ASHOK GAVHALE
CLASS:SE1(BATCH D)

RollNo:205A065

#include<iostream> #include<string.h>
using namespace std; #define max 100; class per_info
{

string lic,dob,bldgrp;

public:

per_info();

per_info(per_info &);

~per_info()

cout<<"\n DESTRUCTOR CALLED !!!!!"<<endl<<"RECORD DELETED


SUCCESSFULLY !!!!";

friend class student ;

};

class student

string name,address,year;

char div;

int roll_no;

long mob;

static int cnt;

public:

void create(per_info &);

void display(per_info &);

inline static void inccnt()


{

cnt++;

inline static void showcnt()

cout<<"\n TOTAL NUMBER OF RECORDS ARE :"<<cnt;

student();

student(student &);

~student()

cout<<"\n DESTRUCTOR IS CALLED !!!"<<endl<<"RECORDS DELETED


SUCCESSFULLY !!!!";

};

int student::cnt; student

:: student()

name="srushti vhare";

address="Dharashiv";

year="SECOMP";

div='A';

roll_no=20581;

mob=8605687730;

per_info::per_info()

{
lic="ABCD123"; dob="18-9-2004";

bldgrp="o+";

student::student(student &obj)

this->name=obj.name; this-

>address=obj.address; this->year=obj.year;

this->div=obj.div; this-

>roll_no=obj.roll_no;

this->mob=obj.mob;

per_info::per_info(per_info &obj)

lic=obj.lic;

dob=obj.dob;

bldgrp=obj.bldgrp;

void student::create(per_info &obj)

cout<<"\n Name :";

cin>>name;

cout<<"\n Address :";

cin>>address;

cout<<"\n Date of birth :";

cin>>obj.dob;

cout<<"\n Year :";

cin>>year;
cout<<"\n Division :"; cin>>div; cout<<"\n Roll Number :"; cin>>roll_no; cout<<"\n Blood

Group :"; cin>>obj.bldgrp;

cout<<"\n License Number :";

cin>>obj.lic; cout<<"\n Mobile

Number :";

cin>>mob;

void student::display(per_info &obj)

cout<<"\n *********Student Information

********"; cout<<"\n Name :"<<name; cout<<"\n

Address :"<<address; cout<<"\n Date of birth :"<<obj.dob;

cout<<"\n Year :"<<year; cout<<"\n Division :"<<div;

cout<<"\n Roll Number :"<<roll_no; cout<<"\n Blood

Group :"<<obj.bldgrp; cout<<"\n License Number

:"<<obj.lic; cout<<"\n Mobile Number :"<<mob;

cout<<"\n******************************";

int main()

int n;

int ch; char ans;

cout<<"\n Enter

No Of Student :";

cin>>n;

cout<<"\n***********************";

student *sobj=new student[n];

per_info *pobj=new per_info[n];


do

cout<<"\n Menu \n 1.Create Databse \n 2.Display Database \n 3.Copy Constructor \n


4.Default Constructor \n 5.Delete(Destructor)";

cout<<"\nEnter Your Choice :";

cin>>ch;

switch(ch)

case 1:

for(int i=0;i<n;i++)

{
sobj[i].create(pobj[i]);
sobj[i].inccnt();

break;

case 2:

{
sobj[0].showcnt();

for(int i=0;i<n;i++)
{
sobj[i].display(pobj[i]);

break;

case 3:

{
student obj1;

per_info obj2;

obj1.create(obj2);

student obj3(obj1);

per_info obj4(obj2);

cout<<"\n Copy Constructor Is Called";

obj3.display(obj4);

break;

case 4:

student obj1;

per_info obj2;

cout<<"\n Default Constructor Is Called ";

obj1.display(obj2);

break;

case 5:

delete [] sobj;

delete [] pobj;

cout<<"\n Want To Continue :(y/n)";

cin>>ans;

}while(ans=='y');

return 0;}
********************ASSIGNMENT NO3****************************
Name: MANSI ASHOK GAVHALE
CLASS:SE1(BATCH D)

RollNo:205A065

#include<iostream>

using namespace std; class

publication

public:

string title;

float price;

};

class Book:public publication

public:

int pages;

void getdata()

cout<<"\n Enter Title Of Book :";

cin>>title; cout<<"\n Enter

Pages Of Book :";

cin>>pages; cout<<"\n

Enter Price Of Book :";

cin>>price;

void display()
{

cout<<"\n*********BOOK INFORMATION********";

cout<<"\n BOOK NAME :"<<title;

cout<<"\n NUMBER OF PAGES :"<<pages;

cout<<"\n BOOK PRICE :"<<price;

cout<<"\n==================================";

};

class Tape:public publication

public:

float min;

void getdata()

cout<<"\n Enter Title Of Tape :";

cin>>title;

cout<<"\n Enter Time Of Tape :";

cin>>min; cout<<"\n

Enter Price Of Tape :";

cin>>price;

void display()

cout<<"\n*********TAPE INFORMATION********";

cout<<"\n TAPE NAME :"<<title; cout<<"\n TIME

OF TAPE :"<<min; cout<<"\n TAPE PRICE :"<<price;

cout<<"\n==================================";

};

int main()
{

Book b[100];

Tape t[100];

int i,n,m; char

ch;

do

cout<<"\n How Many Book You Want To Add :";

cin>>n;

cout<<"\n How Many Tape You Want To Add :";

cin>>m;

for(i=0;i<n;i++)

b[i].getdata();

for(i=0;i<m;i++)

t[i].getdata();

for(i=0;i<n;i++)

b[i].display();

for(i=0;i<m;i++)

t[i].display();

cout<<"\n Do You Want To Continue (y/n) ::";

cin>>ch;

}while(ch=='y');
********************ASSIGNMENT NO4****************************
Name: MANSI ASHOK GAVHALE
CLASS:SE1(BATCH D)

RollNo:205A065

#include<iostream> #include<fstream> using namespace std; class Employee

{ public: char

name[20];

int id;

double salary;

void accept()

cout<<"\n Enter Employee Name :";

cin>>name; cout<<"\n

Enter Employee Id :";

cin>>id; cout<<"\n Enter

Employee Salary :";

cin>>salary;

void display()

cout<<"\n********Employee Information*******";

cout<<"\n Employee Name :"<<name; cout<<"\n

Employee Id :"<<id; cout<<"\n Employee Salary

:"<<salary;

};

int main()

Employee e[5];
int i,n;

cout<<"\n How many Employee Imformation Do You Want to Store :";

cin>>n;

fstream f;

f.open("/home/stes/srushti oop practicals/srushti.txt",ios::out);

for(i=0;i<n;i++)

cout<<"\nEnter Info In this Format :(Name/Id/SALARY)";

e[i].accept();

f.write((char *)&e[i],sizeof(e[i]));

f.close();

f.open("/home/stes/srushti oop practicals/srushti.txt",ios::in);

for(i=0;i<n;i++)

cout<<"\nEnter Info In this Format :(Name/Id/SALARY)";

e[i].display();

f.read((char *)&e[i],sizeof(e[i]));

f.close();

return 0;

}
********************ASSIGNMENTNO5*************************
Name: MANSI ASHOK GAVHALE
CLASS:SE1(BATCH D)

RollNo:205A065

#include<iostream> using

namespace std;

int n;

#define size 10 template<class

T>

void selection(T A[size])

int i,j,min; T

temp; for(i=0;i<n-

1;i++)

{ min=i;

for(j=i+1;j<n;j++)

if(A[j]<A[min])

min=j;

temp=A[i];

A[i]=A[min];

A[min]=temp;

cout<<"\nSorted Element :";


for(i=0;i<n;i++)

cout<<A[i];

cout<<"\n"; }

int main()

{ int A[size];

float B[size];

int i;

cout<<"\n How many Integer elements do you want to store :";

cin>>n; cout<<"\Enter Integer

Elements :";

for(i=0;i<n;i++)

cout<<"A["<<i<<"] =";

cin>>A[i];

selection(A); cout<<"\n How many Float elements do you

want to store :";

cin>>n; cout<<"\Enter Float

Elements :";

for(i=0;i<n;i++)

cout<<"B["<<i<<"] =";

cin>>B[i];

selection(B);

}
********************ASSIGNMENTNO6*************************
Name: MANSI ASHOK GAVHALE
CLASS:SE1(BATCH D)

RollNo:205A065

#include<iostream>

#include<algorithm>

#include<vector> using

namespace std;

int n;

class Item

public: char

name[10];

int quantity;

int cost; int

code;

bool operator==(const Item& i1)

if(code==i1.code)

return 1;

return 0;

bool operator<(const Item& i1)

if(code<i1.code)
return 1;

return 0;

};

vector <Item> o1;

void print(Item & i1);

void display(); void

insert(); void

search();

void dlt();

bool compare(const Item &i1,const Item &i2)

return i1.cost < i2.cost;

int main()

int ch;

cout<<"How Many Product Want To Store :";

cin>>n;

do

cout<<"\n******Menu*****";

cout<<"\n1.Insert";

cout<<"\n2.Display";

cout<<"\n3.Search";

cout<<"\n4.Sort";

cout<<"\n5.Delete";

cout<<"\n6.Exit:"; cout<<"\nEnter

Your Choice :"; cin>>ch;


switch(ch)

{ case 1:

insert();

break; case

2:

display();

break; case

3:

search();

break; case

4:

sort(o1.begin(),o1.end(),compare);

cout<<"\nSorted On Cost";

display();

break; case

5: dlt();

break; case

6:

exit(0); }

}while(ch!=7);

return 0;

void insert()

for(int i=0;i<n;i++)

Item i1;

cout<<"\nEnter Item Name:";

cin>>i1.name; cout<<"\nEnter

Item Quantity:";
cin>>i1.quantity;

cout<<"\nEnter Item Cost:";

cin>>i1.cost;

cout<<"\nEnter Item Code:";

cin>>i1.code;

o1.push_back(i1); }

void display()

for_each(o1.begin(),o1.end(),print);

void print(Item &i1)

cout<<"\n"; cout<<"\nItem

Name:"<<i1.name; cout<<"\nItem

Quantity:"<<i1.quantity; cout<<"\nItem

Cost:"<<i1.cost; cout<<"\nItem

Code:"<<i1.code;

void search()

vector<Item>::iterator p; Item i1;

cout<<"\nEnter Item Code To Search:";

cin>>i1.code;

p=find(o1.begin(),o1.end(),i1);

if(p==o1.end())

cout<<"\nNot Found";

else

{
cout<<"\nFound"; cout<<"\nItem

Name:"<<p->name; cout<<"\nItem

Quantity:"<<p->quantity; cout<<"\nItem

Cost:"<<p->cost; cout<<"\nItem

Code:"<<p->code;

void dlt()

vector<Item>::iterator p;

Item i1;

cout<<"\nEnter Item Code To Delete:";

cin>>i1.code;

p=find(o1.begin(),o1.end(),i1);

if(p==o1.end())

cout<<"\nNot Found";

else

o1.erase(p);

cout<<"\nDeleted";

}
********************ASSIGNMENTNO7********************
Name: MANSI ASHOK GAVHALE
CLASS:SE1(BATCH D)

RollNo:205A065

#include<iostream>

#include<map>

#include<string> using

namespace std; int

main()

typedef map<string,int> maptype; maptype populationmap;

populationmap.insert(pair<string,int>("Maharashtra",5555555));

populationmap.insert(pair<string,int>("Rajasthan",1111111));

populationmap.insert(pair<string,int>("Karnataka",2222222));

populationmap.insert(pair<string,int>("Punjab",333333));

populationmap.insert(pair<string,int>("Bengal",444444));

maptype::iterator iter; string state_name;

cout<<"\n*********Popultion Of State In India ********";

cout<<"\nSize Of PopulationMap :"<<populationmap.size();

cout<<"\n Enter Name Of The State :"; cin>>state_name;

iter=populationmap.find(state_name); if(iter !=

populationmap.end())

cout<<state_name<<"'s population is"<<iter->second;

else

cout<<"\nkey Is Not In PopulationMap"<<"\n";

populationmap.clear();

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy