Professional Documents
Culture Documents
ASSIGNMENT-1 (1) //design The Emp Class and Display The Emp Information Get - Info and Display - Info Where Get - Info Is A Private Member Function.
ASSIGNMENT-1 (1) //design The Emp Class and Display The Emp Information Get - Info and Display - Info Where Get - Info Is A Private Member Function.
PRASAD
SYIT-C 6036
ASSIGNMENT-1(1)
//Design the emp class and display the emp information get_info() and display_info() where
get_info is a private member function.//
#include<iostream.h>
#include<conio.h>
class emp
{
int id,salary;
char name[10];
void get_info();
public:
void display()
{
get_info();
clrscr();
cout<<"\n\n ***** Employee Database *****\n\n" ;
cout<<"Employee ID :- "<<id<<"\n";
cout<<"Employee Name :- "<<name;
cout<<"\nEmployee Salary :- "<<salary;
}
};
clrscr();
emp e;
e.display();
getch();
}
OUTPUT :-
ASMITA.B.PRASAD
SYIT-C 6036
ASSIGNMENT-1(2)
//Design a class student containing get_info() and display_info() function used for reading
and displaying where get_info will be a private method.//
#include<iostream.h>
#include<conio.h>
class stud
{
int roll,percentage;
char name[10];
void get_info();
public:
void display()
{
get_info();
clrscr();
cout<<"\n\n ***** Student Database *****\n\n" ;
cout<<"Student Roll No. :- "<<roll<<"\n";
cout<<"Student Name :- "<<name;
cout<<"\nStudent percentage :- "<<percentage;
}
};
s.display();
getch();
}
OUTPUT:-
ASMITA.B.PRASAD
SYIT-C 6036
ASSIGNMENT-1(3)
#include<iostream.h>
#include<conio.h> #include<stdio.h>
class demo
{
int n,f,i,r,d,t,re;
void read();
public:
void fact();
void pal();
void arm();
void rev();
};
read();
while(n!=0)
{
d=n%10;
r=(r*10)+d;
n=n/10;
}
cout<<"\nReverse of number is :- "<<r;
}
void demo :: pal()
{
flushall();
t=0;
re=0;
cout<<"\n\n*** To check for Palindrome ***\n\n ";
read();
t=n;
while(n!=0)
{
d=n%10;
re=(re*10)+d;
n=n/10;
}
cout<<"Revere of entered number is :- "<<re;
if(re==t)
cout<<"\nIt is a Palindrome";
else
cout<<"Not a Palindrome !!!\n ";
}
ASMITA.B.PRASAD
SYIT-C 6036
while(m!=0)
{
V = m % 10;
rv = rv + (v*v*v);
m = m / 10;
}
if(rv==t)
cout<<"\nIt is an Armstrong Number\n";
else
cout<<"Not an Armstrong Number !!!\n ";
}
void main()
{
clrscr();
demo d;
d.fact();
d.rev();
d.pal();
d.arm();
getch();
}
ASMITA.B.PRASAD
SYIT-C 6036
OUTPUT:-
ASMITA.B.PRASAD
SYIT-C 6036
ASSIGNMENT-2(1)
//C++ program of friend function for adding two complex numbers using single class.//
#include<iostream.h>
#include<conio.h>
class complex
{
int r1,r2,i1,i2;
int sum_r,sum_i;
public:
void get();
friend void add(complex);
};
void add(complex c)
{
c.sum_r = c.r1 + c.r2;
void main()
{
clrscr();
complex c;
c.get();
add(c);
getch();
}
OUTPUT:-
ASMITA.B.PRASAD
SYIT-C 6036
ASSIGNMENT-2(2)
//C++ program for adding two different distance and display its sum using two classes.//
#include<iostream.h>
#include<conio.h>
class distance2;
class distance1
{
float km;
public:
void get1()
{
cout<<"\n\nEnter Total Distance Travelled in KILOMETRES:- ";
cin>>km;
}
class distance2
{
float m,cm;
public:
void get2()
{
cout<<"\n\nEnter Total Distance travelled in METERS:-;
cin>>m;
cout<<"\n\nEnter Total Distance travelled in CM :-;
cin>>cm;
void main()
{
clrscr();
distance1 d1;
distance2 d2;
cout<<"\n\n ***** Program to Calculate Total Distance ***** ";
d1.get1();
d2.get2();
sum(d1,d2);
getch();
}
OUTPUT:-
ASMITA.B.PRASAD
SYIT-C 6036
ASMITA.B.PRASAD
SYIT-C 6036
ASSIGNMENT-2(3)
// C++ program for addition of two matrices from two different classes and display its sum.//
#include<iostream.h>
#include<conio.h>
class mat2;
class mat1
{
int a[5][5],i,j;
public:
void get1();
friend void add(mat1,mat2);
};
class mat2
{
int b[5][5],i,j;
public:
void get2();
ASMITA.B.PRASAD
SYIT-C 6036
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
c[i][j]=m.a[i][j]+n.b[i][j];
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cout<<c[i][j]<<" ";
}
ASMITA.B.PRASAD
SYIT-C 6036
void main()
{
clrscr();
mat1 m;
mat2 n;
m.get1();
n.get2();
add(m,n);
getch();
}
OUTPUT:-
ASMITA.B.PRASAD
SYIT-C 6036
ASSIGNMENT-3(1)
// Program for Operator Overloading using Unary minus Operator.//
#include<iostream.h>
#include<conio.h>
class minus
{
int A;
public:
void get()
{
cout <<"\nEnter a number :- ";
cin>>A;
}
void operator - ();
};
void main()
{
clrscr();
minus m1,m2,m3;
m1.get();
m2.get();
m3.get();
- m1;
- m2;
ASMITA.B.PRASAD
SYIT-C 6036
- m3;
getch();
}
OUTPUT:-
ASMITA.B.PRASAD
SYIT-C 6036
ASSIGNMENT-3(2)
//C++ program to Adding the timing of Two Clocks and also pass object as argument.//
#include<iostream.h>
#include<conio.h>
class time2;
class time1
{
int hr,min;
public:
void gettime(int a,int b)
{
hr=a;
min=b;
}
friend void operator +(time1,time2);
};
class time2
{
int h,m;
public:
void getdata(int p,int q)
{
h=p;
m=q;
}
friend void operator +(time1,time2);
};
time1 t1;
time2 t2;
t1.gettime(100,100);
t2.getdata(50,50);
t1+t2;
getch();
}
OUTPUT:-
ASMITA.B.PRASAD
SYIT-C 6036
ASSIGNMENT-3(3)
// C++ program to Concatenate Two Strings.//
#include <iostream.h>
#include <conio.h>
#include <string.h>
class Add
{
char str[80] ;
public :
void getdata()
{
cout <<"\nEnter String1 :- " ;
cin>>str ;
}
void showdata()
{
cout<<str;
}
Add operator + (Add s)
{
Add s3 ;
strcpy ( s3.str , str) ;
strcat ( s3.str , " ") ;
strcat ( s3.str , s.str) ;
return s3 ;
}
};
void main ()
{
clrscr () ;
cout<<"\n\n ***Program to Concatenate two Strings *** \n\n";
Add a1 , a2 , a3 ;
a1.getdata () ;
a2.getdata () ;
ASMITA.B.PRASAD
SYIT-C 6036
a3 = a1 + a2 ;
cout << "\nString 1 :- " ;
a1.showdata () ;
cout << "\nString 2 :- " ;
a2.showdata () ;
cout << "\n\nConcatenation of both strings :- " ;
a3.showdata () ;
getch () ;
}
OUTPUT:-