1 Simple Message Display Coding
1 Simple Message Display Coding
1 Simple Message Display Coding
BATCH : 2014-2017
OUTPUT:
1 SIMPLE MESSAGE DISPLAY
****************************
Enter name: Boopathi
Enter age: 19
Father name: Nagaraj
Mother name: Eswari
SCHOOL OF BUSINESS MANAGEMENT
PAGE NO:
BATCH : 2014-2017
2 ARITHMATIC OPERATORS
******************************
CODING:
#include<iostream.h>
#include<conio.h>
void main()
{
int A,B,C;
clrscr();
cout<<"ARITHMATIC OPERATORS\n";
cout<<"********************\n";
cout<<"INPUT\n";
cout<<"******\n";
cout<<"Enter the value for A\n";
cin>>A;
cout<<"Enter the value for B\n";
cin>>B;
cout<<"OUTPUT\n";
cout<<"******\n";
C=A+B;
cout<<"\n Addition is:"<<C;
C=A-B;
cout<<"\n Subtraction is:"<<C;
C=A*B;
cout<<"\n Multiplication is:"<<C;
C=A/B;
cout<<"\n Division is:"<<C;
getch();
}
PAGE NO:
BATCH : 2014-2017
OUTPUT:
2 ARITHMATIC OPERATORS
*****************************
INPUT
******
Enter the value of A:2
Enter the value of B:2
OUTPUT
********
ADDITION IS: 4
SUBTRACTION IS: 0
MULTIPLICATION IS: 4
DIVISION IS: 1
PAGE NO:
BATCH : 2014-2017
PAGE NO:
BATCH : 2014-2017
OUTPUT:
PAGE NO:
BATCH : 2014-2017
PAGE NO:
BATCH : 2014-2017
OUTPUT:
is POSTIVE number
PAGE NO:
BATCH : 2014-2017
PAGE NO:
BATCH : 2014-2017
if(n==9)
cout<<"Nine";
getch();
}
OUTPUT:
PAGE NO:
BATCH : 2014-2017
PAGE NO:
BATCH : 2014-2017
cout<<"\nOUTPUT\n";
cout<<"******\n";
if(g=='m'&&yos>10&&qual==1)
sal=15000;
else
if(g=='m'&&yos>10&&qual==0)
sal=10000;
else
if(g=='m'&&yos<=10&&qual==0)
sal=8000;
else
if(g=='m'&&yos<=10&&qual==1)
sal=9500;
if(g=='f'&&yos>10&&qual==1)
sal=13000;
else
if(g=='f'&&yos>10&&qual==0)
sal=8000;
else
if(g=='f'&&yos<=10&&qual==0)
sal=5000;
else
if(g=='f'&&yos<=10&&qual==1)
sal=7000;
cout<<"SALARY OF EMPLOYEE="<<sal;
getch();
return 0;
}
PAGE NO:
BATCH : 2014-2017
OUTPUT:
PAGE NO:
BATCH : 2014-2017
Enter qualification : 0
OUTPUT:
********
SALARY OF EMPLOYEE= 10000
PAGE NO:
BATCH : 2014-2017
INPUT:
******
Enter name: Aarthi
SCHOOL OF BUSINESS MANAGEMENT
PAGE NO:
BATCH : 2014-2017
Enter gender: F
Enter year of service: 5
Enter qualification : 0
OUTPUT:
********
SALARY OF EMPLOYEE= 5000
PAGE NO:
BATCH : 2014-2017
7.ARITHMETIC OPERATION
****************************
CODING:
#include<iostream.h>
#include<conio.h>
class arithmetic
{
float X,Y,a,s,m,d,M;
public:
void getdata();
void add();
void sub();
void mul();
void div();
void mod();
void display();
};
void arithmetic::getdata()
{
cout<<"ARITHMETIC OPERATION\n";
cout<<"*********************\n";
cout<<"INPUT\n";
cout<<"*****\n";
cout<<"\nEnter the value of X=";
SCHOOL OF BUSINESS MANAGEMENT
PAGE NO:
BATCH : 2014-2017
cin>>X;
cout<<"\nEnter the value of Y=";
cin>>Y;
}
void arithmetic::add()
{
a=X+Y;
}
void arithmetic::sub()
{
s=X-Y;
}
void arithmetic::mul()
{
m=X*Y;
}
void arithmetic::div()
{
d=X/Y;
}
void arithmetic::mod()
{
M=(int)X%(int)Y;
}
void arithmetic::display()
{
cout<<"\nOUTPUT";
cout<<"\n*******\n";
cout<<"\nADDITION is
:"<<a;
cout<<"\nSUBTRACTION is :"<<s;
cout<<"\nMULTIPLICATION is :"<<m;
cout<<"\nDIVISION is
:"<<d;
cout<<"\nMODULATION is :"<<M;
}
void main()
{
clrscr();
arithmetic O;
O.getdata();
O.add();
O.sub();
O.mul();
SCHOOL OF BUSINESS MANAGEMENT
PAGE NO:
BATCH : 2014-2017
O.div();
O.mod();
O.display();
getch();
}
OUTPUT:
7.ARITHMETIC OPERATION
*************************
ARITHMETIC OPERATION
***********************
INPUT
******
Enter the value of X : 5
Enter the value of Y : 2
OUTPUT
*******
ADDITION is
:7
SUBTRACTION is
:3
MULTIPLICATION is
: 10
DIVISION is
: 2.5
MODULATION is
:1
PAGE NO:
BATCH : 2014-2017
8. STRING OVERLOADING
**************************
CODING:
#include<iostream.h>
#include<conio.h>
#include<string.h>
class string
{
private:
char st4[30];
char st1[15];
char st2[15];
char st3[30];
public:
void read();
void concat();
void cmpr();
void strleng();
};
void string::read()
{
cout<<"STRING OVERLODING\n";
SCHOOL OF BUSINESS MANAGEMENT
PAGE NO:
BATCH : 2014-2017
cout<<"******************\n";
cout<<"\nINPUT\n";
cout<<"*****\n";
cout<<"\nEnter the first string:"<<endl;
cin>>st1;
cout<<"\nEnter the second string:"<<endl;
cin>>st2;
}
void string::concat()
{
strcpy(st3,st1);
strcat(st3,"");
strcat(st3,st2);
cout<<"\nOUTPUT\n";
cout<<"******\n";
cout<<"\nCONCATENATION\n";
cout<<"-------------\n";
cout<<"\nConcatenation of the String:"<<st3;
}
void string::cmpr()
{
cout<<"\n\nCOMPARISON\n";
cout<<"----------";
if(strcmp(st1,st2)==0)
cout<<"\n\nComparison of two strings are equal"<<endl;
else
cout<<"\n\nComparison of two strings are not equal"<<endl;
}
void string::strleng()
{
int length;
length=strlen(st3);
cout<<"\nLENGTH\n";
cout<<"------\n";
cout<<"\nLength of string entered:"<<length<<endl;
}
void main()
{
string x;
SCHOOL OF BUSINESS MANAGEMENT
PAGE NO:
BATCH : 2014-2017
clrscr();
x.read();
x.concat();
x.cmpr();
x.strleng();
getch();
}
OUTPUT:
8. STRING OVERLOADING
**************************
STRING OVERLOADING
*********************
INPUT
*****
Enter the first string : Guptha
Enter the second string :Arun
OUTPUT
*******
CONCATENATION
--------------------------Concatenation of the string : GupthaArun
COMPARISON
--------------------Comparison of two strings are not equal
LENGTH
-----------SCHOOL OF BUSINESS MANAGEMENT
PAGE NO:
BATCH : 2014-2017
9. BANK TRANSACTION
**********************
CODING:
#include<iostream.h>
#include<conio.h>#include<iomanip.h>
class bank
{
char name[20];
int acno;
char actype[4];
float balance;
public:
bank()
{
cout<<"\nBANK TRANSACTION";
cout<<"\n****************\n";
cout<<"\nINPUT";
cout<<"\n*****";
cout<<"\n\n Constructor invoked!";
SCHOOL OF BUSINESS MANAGEMENT
PAGE NO:
BATCH : 2014-2017
acno=0000;
balance=0.0;
}
void init();
void deposit();
void withdraw();
void disp_det();
};
void bank::init()
{
cout<<"\n\n New account:";
cout<<"\n\n Enter the name of the depositer:";
cin>>name;
cout<<"\n\n Enter the account number:";
cin>>acno;
cout<<"\n\n Enter the account type:(CCUR/SAMG/FD/RD/DMAT)";
cin>>actype;
cout<<"\n\n Enter the amount to deposit:";
cin>>balance;
}
void bank::deposit()
{
float more;
cout<<"\n\n depositing";
cout<<"\n\n Enter the ammount of deposit";
cin>>more;
balance+=more;
}
void bank::withdraw()
{
float amt;
cout<<"\n\n withdraw!";
cout<<"\n\n Enter the amount to withdraw:";
cin>>amt;
balance-=amt;
}
void bank::disp_det()
{
cout<<"\n\n Account details";
cout<<"\n\n Name of the depositer:"<<name<<endl;
cout<<"\n\n Account number:"<<acno<<endl;
SCHOOL OF BUSINESS MANAGEMENT
PAGE NO:
BATCH : 2014-2017
PAGE NO:
BATCH : 2014-2017
OUTPUT:
9. BANK TRANSACTION
**********************
BANK TRANSACTION
********************
INPUT
*****
Constructor invoked!
Enter 0 to exit
1.Initialize a New Account
2.Deposite
3.Withdraw
SCHOOL OF BUSINESS MANAGEMENT
PAGE NO:
BATCH : 2014-2017
4.Account Status
Choose your option:1
OUTPUT
*******
Enter the name of the depositer: Alex
Enter the account number: 45450
Enter the account type: (CCUF/SAMG/FD/RD/DMAT)SAMG
Enter the amount to deposit: 1,00,000
INPUT
*****
Enter 0 to exit
1.Initialize a New Account
2.Deposite
3.Withdraw
4.Account Status
Choose your option:2
OUTPUT
*******
Depositing
Enter the amount of deposit: 2,000
INPUT
*****
Enter 0 to exit
1.Initialize a New Account
2.Deposite
3.Withdraw
4.Account Status
SCHOOL OF BUSINESS MANAGEMENT
PAGE NO:
BATCH : 2014-2017
OUTPUT
*******
Account details
Name of the depositer : Alex
Account number: 45450
Account type: SAMG
Balance: Rs.97,000
PAGE NO:
BATCH : 2014-2017
PAGE NO:
BATCH : 2014-2017
double netamt;
int pf,hra,da;
char name[10],add[15];
char dept[15],grade;
void input();
void disp();
};
class pay:public emp
{
public:
void calc();
};
void emp::input()
{
clrscr();
read:
cout<<"\nEMPLOYEE DETAILS";
cout<<"\n****************\n";
cout<<"\nINPUT";
cout<<"\n*****";
cout<<"\n\nEnter the employee number:";
cin>>empno;
cout<<"\nEnter the employee name:";
cin>>name;
cout<<"\nEnter the employee address:";
cin>>add;
cout<<"\nEnter the employee department:";
cin>>dept;
cout<<"\nEnter the employee salary:";
cin>>salary;
cout<<"\nEnter the employee grade[a,b,c]:";
cin>>grade;
SCHOOL OF BUSINESS MANAGEMENT
PAGE NO:
BATCH : 2014-2017
cout<<"\n";
}
void pay::calc()
{
if(grade=='a')
{
pf=200;
hra=300;
da=50;
}
else if(grade=='b')
{
pf=150;
hra=300;
da=50;
}
else if(grade=='c')
{
pf=300;
hra=100;
da=300;
}
netamt=salary+pf+hra+da;
}
void emp::disp()
{
cout<<"\nPAY SLIP";
cout<<"\n********\n";
cout<<"\nOUTPUT";
cout<<"\n*****";
cout<<"\n\nEmployee number:"<<empno;
cout<<"\n\nEmployee name:"<<name;
SCHOOL OF BUSINESS MANAGEMENT
PAGE NO:
BATCH : 2014-2017
cout<<"\n\nEmployee address:"<<add;
cout<<"\n\nEmployee department:"<<dept;
cout<<"\n\nEmployee salary:"<<salary;
cout<<"\n\nNet Salary:"<<netamt;
}
void main() {
clrscr();
pay a;
char d;
read:
a.input();
a.calc();
a.disp();
cout<<"\n\n\t\t\t Do you want to continue [y/n]:";
cin>>d;
if(d=='y')
goto read;
else
getch();}
OUTPUT:
PAGE NO:
BATCH : 2014-2017
PAGE NO:
BATCH : 2014-2017
*****
Enter the employee number: 46
Enter the employee name: GUPTHA
Enter the employee address: CHENNAI
Enter the employee department: MANAGER
Enter the employee salary: 65,000
Enter the employee grade[a,b,c] : c
PAY SLIP
********
OUTPUT
*******
Employee number : 46
Employee name: GUPTHA
Employee address: CHENNAI
Employee department: MANAGER
Employee salary:65,000
Net salary:65,700
Do you want to continue [y/n]:n
PAGE NO:
BATCH : 2014-2017
void input(void);
void output(void);
friend void dis (FIRST,SECOND);
};
class SECOND
{
private:
int s1;
float s2;
public:
void input(void);
void output(void);
friend void dis(FIRST,SECOND);
};
void FIRST::input(void)
{
cout<<"\n\nINPUT";
cout<<"\n****";
cout<<"\n\nENTER THE INTEGER VALUE:";
cin>>f1;
cout<<"\nENTER THE FLOAT VALUE:";
cout.precision(2);
cin>>f2;
}
void FIRST::output(void)
{
cout<<"\n\n!!first input set!!"<<"\n";
cout<<"\n\n->"<<f1;
cout<<"\n\n->"<<f2;
}
void SECOND::input(void)
{
SCHOOL OF BUSINESS MANAGEMENT
PAGE NO:
BATCH : 2014-2017
cout<<"\n\nINPUT";
cout<<"\n*****";
cout<<"\n\nENTER THE INTEGTER VALUE:";
cin>>s1;
cout<<"\nENTER THE FLOAT VALUE:";
cout.precision(2);
cin>>s2;
}
void SECOND::output(void)
{
cout<<"\n\n!! second input set !!"<<"\n";
cout<<"\n\n->"<<s1;
cout<<"\n\n->"<<s2;
}
void dis(FIRST F,SECOND S)
{
int i;
float f;
i=F.f1+S.s1;
f=F.f2+S.s2;
cout<<"\n\n\nTHE RESULT OF THE OPERATION";
cout<<"\n***************************";
cout<<"\n\n"<<F.f1<<"+"<<S.s1<<"="<<i;
cout<<"\n\n"<<F.f2<<"+"<<S.s2<<"="<<f<<"\n";
}
void main()
{
clrscr();
{
cout<<"\nIMPLEMENTING OF FRIENDLY FUNCTION"<<"\n";
cout<<"\n*********************************"<<"\n";
FIRST fir;
SCHOOL OF BUSINESS MANAGEMENT
PAGE NO:
BATCH : 2014-2017
SECOND sec;
char a='y';
while(a=='y')
{
fir.input();
sec.input();
fir.output();
sec.output();
dis(fir,sec);
cout<<"\n\n\n\t\t\t DO YOU WANT TO CONTINUE [Y/N] :";
cin>>a;
getch();
}
}
}
OUTPUT:
PAGE NO:
BATCH : 2014-2017
->2
->2.2
!! Second input set !!
->2
->2.2
THE RESULT OF OPERATION
**************************
2+2=4
2.2+2.2=4.4
DO YOU WANT TO CONTINUE [Y/N] :N
PAGE NO:
BATCH : 2014-2017
{
}
void shape::peri(void)
{
}
class square:public shape
{
double side;
public:
void input(void);
void area(void);
void peri(void);
};
class rectangle:public shape
{
double side;
public:
void input(void);
void area(void);
void peri(void);
};
class triangle:public shape
{
double h,a,b,c,ba;
public:
void input(void);
void area(void);
void peri(void);
};
void square::input(void)
{
cout<<"\n\nSQUARE";
SCHOOL OF BUSINESS MANAGEMENT
PAGE NO:
BATCH : 2014-2017
cout<<"\n******";
cout<<"\n\n Enter the value of side:";
cin>>side;
}
void square::area(void)
{
double area;
area=pow(side,2);
cout<<"\n\n Area of the square is:"<<area;
}
void square::peri(void)
{
double peri=4*side;
cout<<"\n\nPerimeter of the square is:"<<peri;
}
void rectangle::input(void)
{
double length,base;
cout<<"\n\nRECTANGLE";
cout<<"\n*********";
cout<<"\n\nEnter the length:";
cin>>length;
cout<<"\n\nEnter the breadth:";
cin>>base;
}
void rectangle::area(void)
{
double length,base;
double area=length*base;
cout<<"\n\nArea of the rectangle is:"<<area;
}
void rectangle::peri(void)
SCHOOL OF BUSINESS MANAGEMENT
PAGE NO:
BATCH : 2014-2017
{
double length,base;
double peri=2*(length+base);
cout<<"\n\nPerimeter of the rectangle is:"<<peri;
}
void triangle::input(void)
{
cout<<"\n\nTRIANGLE";
cout<<"\n********";
cout<<"\n\nEnter the value of first side:";
cin>>a;
cout<<"\n\nEnter the value of second side:";
cin>>b;
cout<<"\n\nEnter the value of third side:";
cin>>c;
cout<<"\nEnter the base:";
cin>>ba;
cout<<"\nEnter the height:";
cin>>h;
}
void triangle::area(void)
{
double area=0.5*ba*h;
cout<<"\n\nArea of the triangle is:"<<area;
}
void triangle::peri(void)
{
double p=(a+b+c);
cout<<"\n\nPerimeter of the triangle:"<<p;
}
void main()
{
SCHOOL OF BUSINESS MANAGEMENT
PAGE NO:
BATCH : 2014-2017
clrscr();
char d;
read:
cout<<"THE VIRTUAL FUNTION";
cout<<"\n*******************";
shape*s,sh;
square sq;
rectangle r;
triangle t;
s=&sh;
s=&sq;
sq.input();
s->area();
s->peri();
s=&r;
r.input();
s->area();
s->peri();
s=&t;
t.input();
s->area();
s->peri();
cout<<"\n\n\n\t\t\tDo You Want To Continue[y/n]:";
cin>>d;
if(d=='y')
goto read;
else
getch();
}
PAGE NO:
BATCH : 2014-2017
OUTPUT:
PAGE NO:
BATCH : 2014-2017
PAGE NO:
BATCH : 2014-2017
void ini(void);
void output(void);
void disp();
};
void TAB::input(void)
{
cout<<"\n\n Enter which table:";
cin>>num;
cout<<"\n\n Enter number of times:";
cin>>n;
}
void TAB::ini(void)
{
int i;
disp();
}
void TAB::disp(void)
{
cout.precision(3);
cout<<setiosflags(ios::showpoint);
cout<<setiosflags(ios::showpos);
for(i=1;i<=n;i++)
{
res=num*i;
cout<<"\n\t"<<setw(4)<<num<<setw(4)<<"*"<<setw(4);
cout<<i<<setw(5)<<"="<<setw(5)<<res;
}
}
void main()
{
clrscr();
char a='y';
SCHOOL OF BUSINESS MANAGEMENT
PAGE NO:
BATCH : 2014-2017
while(a=='y')
{
cout<<"MULTIPLICATION TABLE USING CONSOLE I/O";
cout<<"\n**********************************";
cout<<"\n\nINPUT";
cout<<"\n*****";
TAB t;
t.input();
cout<<"\nOUTPUT";
cout<<"\n******";
cout<<"\n\n Multiplication table";
t.ini();
cout<<"\n\n\n\t\t\t Do You Continue(Y/N)";
cin>>a;
getch();
}}
OUTPUT:
=+5.000
+5.000 * +2
=+10.000
+5.000 * +3
=+15.000
+5.000 * +4
=+20.000
+5.000 * +5
=+25.000
+5.000 * +6
=+30.000
+5.000 * +7
=+35.000
+5.000 * +8
=+40.000
+5.000 * +9
=+45.000
+5.000 * +10
=+50.000
PAGE NO:
BATCH : 2014-2017
PAGE NO: