Object Oriented Using C++ programing collection

Preview:

Citation preview

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 1/400

OBJECT ORIENTED

PROGRAMINGUSING C++

1.#include<iostream.h>

#include<conio.h>main()

{clrscr();

cout<<"ASALAM-U-ALIKUM";cout<<"\n\n MILES CONVERT INTO KILOMETER";

float mile,km;cout<<"\n\nEnter a value in mile";

cin>>mile;km=mile*1.609;

cout<<"\n\n mile="<<mile<<endl<<mile<<"mile"<<"="<<km<<"km"<<endl;cout<<"\n\n THANKS & BYE BYE";

getch();}

2#include<iostream.h>#include<conio.h>

void main(){

clrscr();cout<<"\n\n ASALAM-U-ALIKUM";

cout<<"\n\n INPUT AGE IN YEAR & CONVERT IT INTO DAYS & MONTHES";int age,days,monthes;

cout<<"\n\n input age in years:";cin>>age;

days=365*age;monthes=12*age;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 2/400

cout<<"\n\n age in days:"<<days;cout<<"\n\n age in monthes:"<<monthes;

cout<<"\n\n THANKS & BYE BYE";getch();

}

3#include<iostream.h>#include<conio.h>

main(){

clrscr();cout<<"ASALAM-U-ALIKUM";

cout<<"\n\n square & cube of any No.";long double a,sqr,cube;

cout<<"\n Enter any no:";cin>>a;

sqr=a*a;cube=sqr*a;

cout<<" square of a:"<<sqr;cout<<"\n\n cube of a:"<<cube<<endl;

cout<<"THANKS & BYE BYE";getch();

}#include<iostream.h>

#include<conio.h>

void main(){

clrscr();cout<<"\n\n ASALAM-U-ALIKUM:";

int a,b,c,r,d;cout<<"\n\n Input total pages of a book:";

cin>>a;cout<<"\n\n No of pages a person a read in one day:";

cin>>b;cout<<"\n\n No of days a person has read the book:";

cin>>c;r=a-b*c;

d=b*c;cout<<"\n\n No of paged thet have been read:"<<d;

cout<<"\n\n No of pages remaining:"<<r;cout<<"\n\n THANKS & BYE BYE:";

getch();}

#include<iostream.h>#include<conio.h>

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 3/400

main(){

clrscr();float mile,liter;

cout<<"Input Patrol in liter:";

cin>>liter;mile=5.3*liter;cout<<"patrol="<<liter <<"liter"<<endl;

cout<<"A car can cover the distance:"<<mile<<"mile";getch();

}#include<iostream.h>

#include<conio.h>main()

{clrscr();

cout<<"\n\n ASALAMA-U-ALIKUM";float student,fee,total;

cout<<"\n\n total no of student is class:";cin>>student;

cout<<"fee par student:";cin>>fee;

total=student*fee;cout<<"\n\n total fee collected from the class Rs:"<<total;

cout<<"\n\n ALLAH HAFIZ & BYR BYR:";getch();

}

#include<iostream.h>#include<conio.h>

main(){

clrscr();int c,f;

c=5/9*(f-32);cout<<"Input temperature in fahrenheit";

cin>>f;cout<<"temperature in celsious "<<c;

getch();}

#include<iostream.h>#include<conio.h>

void main(){

clrscr();cout<<"\n\n ASALAM-U-ALIKUM"<<endl;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 4/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 5/400

main(){

clrscr();int code;

cout<<"Enter code No of disk:";

cin>>code;switch (code){

case 1:cout<<"\n\n The disk drive manufacture is Western Digital";break;

case 2:cout<<"\n\n The disk drive manufacture is 3M Corporation";break;

case 3:cout<<"\n\n The disk drive manufacture is Maxell Corporation";break;

case 4:cout<<"\n\n The disk drive manufacture is Sony Corporation";break;

case 5:cout<<"\n\n The disk drive manufacture is Verbatim Corporation";break;

default:cout<<"\n\n invalid Input code";

}getch();

}#include<iostream.h>

#include<conio.h>main()

{clrscr();

float inch,gallon,mile,pound;int value;

cout<<"Input a value:";cin>>value;

switch(value){

case 1:cout<<"input inch & convert into cm:";

cin>>value;inch=value*2.54;

cout<<"inch="<<inch<<"cm";break;case 2:

cout<<"input gallon & convert into liter:";cin>>value;

gallon=value*3.785;cout<<"gallon="<<gallon<<"l";break;

case 3:cout<<"input mile & convert into km:";

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 6/400

cin>>value;mile=value*1.609;

cout<<"mile="<<mile<<"km";break;case 4:

cout<<"input pound & convert into kg";

cin>>value; pound=value*0.4536;cout<<"pound="<<pound<<"kg";break;

}getch();

}#include<iostream.h>

#include<conio.h>main()

{clrscr();

float temp;cout<<"Input temperature";

cin>>temp;if(temp>=25&&temp<=35)

if(temp<35){cout<<"plasent day";}

else{cout<<"cool day";}

elseif(temp>35)

{cout<<"hot day";}else

{cout<<"cool day";}getch();

}#include<iostream.h>

#include<conio.h>main()

{clrscr();

float total,obtained,avg;total=1100;

cout<<"Enter Your obtained marks :";cin>>obtained;

avg=(obtained/1100)*100;

if(avg>=70&&avg<=100)if(avg>=80)

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 7/400

{cout<<"grade is A+:";}else

{cout<<"grade is A:";}else

if(avg>=50&&avg<70)

if(avg>=60){cout<<"grade is B:";}else

{cout<<"grade is C:";}else

if(avg>=33&&avg<50)if(avg>=40)

{cout<<"grade is D:";}else

{cout<<"grade is E:";}else

{cout<<"grade is F:";}getch();

}#include<iostream.h>

#include<conio.h>main()

{clrscr();

int a;cout<<"input your disaire No:";

cin>>a;if(a>=0)

{cout<<"this no is positive:";

}else

if(a<=0){

cout<<"this No is nagitive:";}

elseif(a==0)

{cout<<"this No is zero:";

}else

{cout<<"you input wrong No:";

}getch();

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 8/400

}#include<iostream.h>

#include<conio.h>main()

{

clrscr();char fig;float side,area,base,height;

cout<<"Enter a figure:";

cin>>fig;if(fig=='s'||fig=='S')

{

cout<<"\n\n Enter a side value of square:";cin>>side;

area=side*side;cout<<"\n\n area of square:"<<area;

}else

if(fig=='t'||fig=='T'){

cout<<"\n\n Enter a base of triangle:";cin>>base;

cout<<"\n\n Enter a height of triangle:";cin>>height;

area=base*height/0.5;cout<<"area of triangle:"<<area;

}

getch();

}#include<iostream.h>

#include<conio.h>main()

{clrscr();

float per;char choice;

loop:clrscr();

cout<<"input persantage:";cin>>per;

if(per>=70&&per<=100)if(per<80)

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 9/400

{cout<<"gradeA:";}else

{cout<<"Grade A++:";}else

if(per>=40&&per<69)

if(per<60){cout<<"grade C:";}else

{cout<<"grade B:";}if(per<40)

cout<<" fail";cout<<"\n\n Do you want to cantinue;if yes then press y.if not press n:";

cin>>choice;if((choice=='y')||(choice=='Y'))

{cout<<"\n\n you have pressed y:";goto loop; }

elseif((choice=='n')||(choice=='N'))

{cout<<"\n\n you have pressed n:";cout<<"\n\n THANKS AND BYE BYE:";}

else{cout<<"\n\n wrong input:";

}getch();

}#include<iostream.h>

#include<conio.h>main()

{clrscr();

float grade;char choice;

loop:clrscr();

cout<<"Enter your grade:";cin>>grade;

if(grade>=19&&grade<=22)if(grade>20)

{cout<<"40000";}else

{cout<<"30000";}else

if(grade>=15&&grade<=18)if(grade<16)

{cout<<"20000";}else

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 10/400

{cout<<"25000";}else

if(grade>=10&&grade<=14)if(grade>12)

{cout<<"20000";}

else{cout<<"15000";}else

{cout<<"10000";}cout<<"\n\n Do you want to cantinue;if yes then press y.if not press n:";

cin>>choice;if((choice=='y')||(choice=='Y'))

{cout<<"\n\n you have pressed y:";goto loop; }

elseif((choice=='n')||(choice=='N'))

{cout<<"\n\n you have pressed n:";cout<<"\n\n THANKS AND BYE BYE:";}

else{cout<<"\n\n wrong input:";

}getch();

}#include<iostream.h>

#include<conio.h>main()

{clrscr();

char fig;float side,area,base,height;

cout<<"enter a figure:";cin>>fig;

switch(fig){

case 's':cout<<"\n\n Enter a side value of square:";

cin>>side;area=side*side;

cout<<"\n\n area of square:"<<area;break;case 't':

cout<<"\n\n Enter a base of triangle:";cin>>base;

cout<<"\n\n Enter a height of triangle:";cin>>height;

area=1/2*base*height;cout<<"area of triangle:"<<area;break;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 11/400

default:cout<<"You Enter a wrong Figure";

}

getch();

}#include<iostream.h>#include<conio.h>

main(){

clrscr();float per,total=1100,obtaiend;

while(obtaiend!=-1)

{cout<<" Enter obtained marks:";

cin>>obtaiend; per=(obtaiend/1100)*100;

if(per>=33 && per<=100)if(per>=40)

if(per>=50)if(per>=60)

if(per>=70)if(per>=80)

cout<<"\n\n Grade is A+:"<<endl;else

cout<<"\n\n Grade is A:"<<endl;else

cout<<"\n\n Grade is B:"<<endl;else

cout<<"\n\n Grade is C:"<<endl;else

cout<<"\n\n Grade is D:"<<endl;else

cout<<"\n\n Grade is E"<<endl;else

cout<<"fail"<<endl;}

cout<<"End of Program";getch();}

#include<iostream.h>#include<conio.h>main()

{clrscr();

for(int a=1;a<=4;a++)

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 12/400

{cout<<a<<" ";

for(int b=1;b<=6;b++)if(b%2==0)

cout<<b<<" ";

cout<<endl;

}getch();}#include<iostream.h>

#include<conio.h>

main(){

clrscr();float a=1,b=4;

do{

a=a+1/b;

 b=b+4;}

while(b<=100);

cout<<a;getch();

}#include<iostream.h>

#include<conio.h>main()

{

clrscr();char a='A',b='Z';

for(;a<=b;){cout<<a<<endl;

a++;}getch();}

#include<iostream.h>#include<conio.h>

main()

{clrscr();int a=1,min;

while(a<=20)

{cout<<a<<endl;a++;}

min=1;if(a>=min){cout<<"min no is:" <<min; }

getch();

}#include<iostream.h>#include<conio.h>

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 13/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 14/400

{clrscr();

int a;for(a=4;a>=1;a--)

cout<<"\r* * * ";{

for(int b=1;b<=4;b++)

cout<<"*\t*\n"<<endl;}

for(int i=1;i<=5;i++)cout<<"* ";

getch();}

#include<iostream.h>#include<conio.h>

#include<iomanip.h>main()

{

clrscr();for(int a=1,s=7;a<=7;a++,s--)

{cout<<setw(s);

for(int b=1;b<=a;b++)cout<<b;

cout<<endl;}

getch();}

#include<iostream.h>

#include<conio.h>main()

{clrscr();

for(int a=1;a<=5;a++){for(int b=1;b<=a;b++)

cout<<b<<"\t";cout<<endl;

}

getch();}#include<iostream.h>

#include<conio.h>

main(){

clrscr();

for(int a=1;a<=5;a++)

{

for(int b=1;b<=a;b++)cout<<b<<"\t";cout<<endl;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 15/400

}

getch();

}#include<iostream.h>

#include<conio.h>

main(){clrscr();int a=1,b;

while(a<=5)

{b=1;while(b<=5)

{cout<<a*b<<"\t"; b++;}

cout<<endl;a++;

}

getch();}

#include<iostream.h>

#include<conio.h>main()

{clrscr();

for(int a=1;a<=4;a++){cout<<a<<" ";

for(int b=1;b<=6;b++)

if(b%2==0)cout<<b<<" ";

cout<<endl;

}getch();}

#include<conio.h>#include<iostream.h>

#include<iomanip.h>

main(){clrscr();

for(int a=1,s=1;a<=10;a=a+2){

for(int b=9;b>=a;b--)cout<<"B";cout<<setw(s+=1);

cout<<endl;

}getch();

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 16/400

}

#include<iostream.h>#include<conio.h>

void main()

{

int a[100];int n,i,prime,j,count=0;clrscr();for(i=0;i<=99;i++)

cout<<i<<"\t";

cout<<"\n\n";for(i=0;i<=99;i++)

{for(j=2;j<=i/2;j++)

{ prime = 1;

if(i%j==0){

 prime = 0;

 break;}

}if((prime==1)||(i==1)||(i==2)||(i==3))

{count++;cout<<"\n"<<i;

}

}cout<<"\ntotal prime number is:"<<count;

getch();}

#include<iostream.h>#include<conio.h>main()

{clrscr();long num[10],i,count=1,fact=1;

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

{cout<<"ENTER A NUMBER IN ELEMENT:"<<i<<"=";cin>>num[i];}for(i=0;i<=9;i++)

for(;fact<=num[i]/2;fact++)

{if(num%fact==0)

count=count++;}if(count==1)

cout<<"\n Yes! It is a prime Number:"<<endl;

elsecout<<"Not!It is not a prime Number:"<<endl;getch();

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 17/400

}

#include<iostream.h>#include<conio.h>

main(){

clrscr();

float marks[10],total=1100,avg;int a;for(a=0;a<=9;a++){cout<<"enter a marks";

cin>>marks[a];}

for(a=0;a<=9;a++){avg=(marks[a]/total)*100;

if(avg>=70&&avg<=100)if(avg>=80)

{cout<<"\n grade is A+:";}else

{cout<<"\n grade is A:";}

elseif(avg>=50&&avg<70)

if(avg>=60)

{cout<<"\n grade is B:";}else

{cout<<"\n grade is C:";}else

if(avg>=33&&avg<50)if(avg>=40)

{cout<<"\n grade is D:";}

else{cout<<"\n grade is E:";}

else{cout<<"\n grade is F:";} }

getch();}#include<iostream.h>

#include<conio.h>#include<iomanip.h>

main()

{clrscr();char name[30][10];

long mango[100],banana[100],orange[100],i,n;

int m,o,b;double total[100]={0};

cout<<"Rs.20 per mango,Rs.10 per orange,Rs.5 per banana:";cout<<"\nEnter the num of customers:";cin>>n;

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

{cout<<"Enter a name:";cin>>name[i];

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 18/400

cout<<"Enter the no of mangoes that puchased by "<<name[i];

cin>>mango[i];cout<<"Enter the no of bananas that puchased by customer "<<name[i];

cin>>banana[i];cout<<"Enter the no of oranges that puchased by customer "<<name[i];

cin>>orange[i];

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

{m=20*mango[i];

 b=5*banana[i];

o=10*orange[i];total[i]=m+b+o;}

cout<<"NAME"<<setw(9)<<"MANGOES"<<setw(9)<<"BANANAS"<<setw(17)<<"ORANGES"<<setw(18)<<"TOTAL"<<endl;

for(i=0;i<n;i++){cout<<name[i]<<setw(6)<<mango[i]<<setw(9)<<banana[i]<<setw(15)<<orange[i]<<setw(20)<<total[i]

<<endl;}

getch();}

#include<iostream.h>

#include<conio.h>

void main(){

int a[10];int n,i,prime,j,count=0;

clrscr();

for(i=0;i<=9;i++){cout<<"enter a value in element:"<<i<<"="<<endl;

cin>>a[i];}for(i=0;i<=9;i++)

{for(j=2;j<=a[i]/2;j++){

 prime = 1;

if(a[i]%j==0)

{ prime = 0; break;

}

}if((prime==1)||(a[i]==1)||(a[i]==2)||(a[i]==3))

{count++;cout<<"\n"<<a[i];}

}

cout<<"\ntotal prime number is:"<<count;getch();}

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 19/400

#include<iostream.h>

#include<conio.h>struct player 

{int min,sec;

int p_num;

char p_name[10];}

main()

{clrscr();

 player p[2];

float distance; long i,j,winer,winer_s;cout<<"\n\n\nENTER THE DISTANCE IN CM THAT COVERED BY AN EACH PLAYER: ";

cin>>distance;for(i=0;i<2;i++)

{

cout<<"\nENTER A PLAYER NUMBER: ";cin>>p[i].p_num;

cout<<"\nENTER A PLAYER "<<p[i].p_num<<" NAME: ";

cin>>p[i].p_name;cout<<"\nENTER A TIME IN MINUTES AND SECOUND TAKEN TO COVERD ";

cout<<"THE DISTANCE BY PLAYER:"<<p[i].p_num<<" ";cin>>p[i].min;

cout<<":";cin>>p[i].sec;

}

cout<<"\n\n\t\t****RECORD OF WINER****\n"; j=0;

winer_s=p[0].sec;winer=p[0].min;

for(i=0;i<2;i++){if(winer&&winer_s>p[i].min&&p[i].sec)

winer_s=p[i].sec;

winer=p[i].min;

 j=i;}

cout<<"\nPALYER NUMBER\tPLAYER NAME\t\t PLAYER TIME\n";

cout<<p[j].p_num<<"\t\t"<<p[j].p_name<<"\t\t\t"<<winer<<":"<<winer_s;

getch();}

#include<iostream.h>#include<conio.h>struct employee

{

long c_num;float salary;char e_name[10];

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 20/400

int grade;

};

main(){

clrscr();

employee emp[2];int i,j, max_sal;for(i=0;i<2;i++){

cout<<"\n\n\tENTER A CODE NUMBER OF EMPLOYEE: ";

cin>>emp[i].c_num;cout<<"\nENTER A NAME ";

cin>>emp[i].e_name;cout<<"\nENTER A GRADE";

cin>>emp[i].grade;cout<<"\nENTER A SALARY IN RS:";

cin>>emp[i].salary;

}cout<<"\n\n\n\n\t****EMPLOYEE RECORD WITH MORE SALARY****\n";

max_sal=emp[0].salary;

for(i=0;i<2;i++)if(max_sal<emp[i].salary)

{max_sal=emp[i].salary;

 j=i;}

cout<<"\n\nCODE NUMBER:"<<emp[j].c_num;

cout<<"\n\nNAME: "<<emp[j].e_name;cout<<"\n\nGRADE: "<<emp[j].grade;

cout<<"\n\nSALRY: "<<emp[j].salary;

getch();}#include<iostream.h>

#include<conio.h>struct book 

{

int b_id;char b_name[15];float price;

};

struct order {

double order_id; book my_book[2];};

main()

{clrscr();order id;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 21/400

int i,j,k;

cout<<"Enter a OrderID ";cin>>id.order_id;

for(i=0;i<2;i++){

cout<<"\nEnter a book id ";

cin>>id.my_book[i].b_id;cout<<"\nEnter a book name ";cin>>id.my_book[i].b_name;cout<<"\nEnter a price ";

cin>>id.my_book[i].price;

}cout<<"\n\n\t\t****OUTPUT**** ";

cout<<"\n\n\tOrder id "<<id.order_id;for(i=0;i<2;i++)

{cout<<"\n\n\tBook id "<<id.my_book[i].b_id;

cout<<"\n\n\tBook name "<<id.my_book[i].b_name;

cout<<"\n\n\tPrice "<<id.my_book[i].price;}

getch();

}#include<iostream.h>

#include<conio.h>main()

{clrscr();int day,month,year;

cout<<"ENTER DATE IN (DAYS/MONTHS/YEARS) ";

cin>>day>>month>>year;while ((month>12||day>31))

{cout<<"REENTER DATE ";

cin>>day>>month>>year;}switch(month)

{case 1:

cout<<"January";break;

case 2:cout<<"Febuary";break;case 3:

cout<<"March";break;

case 4:cout<<"Aprail";break;

case 5:cout<<"May";break;case 6:

cout<<"June";break;

case 7:cout<<"July";break;case 8:

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 22/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 23/400

 

getch();

}#include<iostream.h>

#include<conio.h>

void deci(int dec){int t,i,b[9];for(int a=0;a<9;a++)

{if(dec>=1)

{t=dec%2;

dec=dec/2; b[a]=t;

cout<<b[a];}

}

}main()

{

clrscr();int d;

cout<<"Enter a decimal number";cin>>d;

deci(d);getch();

}

#include<iostream.h>#include<conio.h>

#include<math.h>void bina(long bi);

void main(){long bin;

char choice;do

{ clrscr();

cout<<"\n\n\tENTER A BINARY NUMBER : ";cin>>bin;while(bin>=0&&bin<=9)

{cout<<"\n\n\tOOPS!!! ERROR. RE-ENTER : ";

cin>>bin;} bina(bin);

cout<<"\n\n\tWish to continue(Y/N)";

choice=getch();

}

while(choice=='Y'||choice=='y');}void bina(long bi)

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 24/400

{

long digit, a=0, deci=0;for(int count=0;bi>=1;count++)

{digit=bi%10;

a=digit*pow(2,count);deci+=a;

 bi/=10;}

cout<<"\n\n\tTHE DECIMAL NUMBER IS : "<<deci;

}#include<iostream.h>

#include<conio.h>void fibonacii(int num)

{int a=1,b=0,i;

for(i=0;i=num%2;i++)

{a+=b;

cout<<b<<" ";

 b+=a;cout<<a<<" ";

}}

main(){

clrscr();

int no;cout<<"Enter a number of element required ";

cin>>no;fibonacii(no);

getch();}#include<iostream.h>

#include<conio.h>

int power(int base,int pow);

main(){clrscr();

int a,b,c;

cout<<"Enter first number ";cin>>a;

cout<<"Enter secound number ";cin>>b;c=power(a,b);

cout<<"\n\n"<<c;

getch();}int power(int base,int pow)

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 25/400

{

int j=1,i=1;while(i<=pow)

{ j=base*j;

i++;}

return j;}#include<iostream.h>#include<conio.h>

int Reverse(long num)

{long reverse=0,t;

while(num!=0){

t=num%10;reverse=(reverse*10)+t;

num=num/10;

}return reverse;

}

main(){

char ch;

long no,rev;do

{

clrscr();cout<<"\n\nEnter a number";

cin>>no;rev=Reverse(no);

cout<<"\n\nReverse number is "<<rev;cout<<"\n\nWish to countinue (Y/N) ";ch=getch();

}while(ch=='Y'||ch=='y');

}

#include<iostream.h>#include<conio.h>float power(float a,float b)

{

float j=1,i;for(i=1.0;i<=b;i++)

 j=a*j;return j;}

main()

{clrscr();float a;float b;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 26/400

cout<<"Enter a first number ";

cin>>b;cout<<"Enter a secound number ";

cin>>a;float z=power(b,a);

cout<<"Result is "<<z ;

getch();}#include<iostream.h>

#include<conio.h>

void add(int a[],int b[],int c[],int n);main()

{clrscr();int a1[5],b1[5],num,c1[5];

int i;cout<<"Enter a lenth of arrays ";

cin>>num;

cout<<"\n\nEnter a value of first array ";for(i=0;i<num;i++)

cin>>a1[i];

cout<<"\n\nEnter a value of secound array ";for(i=0;i<num;i++)

cin>>b1[i];add(a1,b1,c1,num);

getch();}

void add(int a[],int b[],int c[],int n)

{int j;

for(j=0;j<n;j++){c[j]=a[j]+b[j];

cout<<" "<<c[j];}

}#include<iostream.h>

#include<conio.h>

struct student{int rno[5];

float marks[5];

char name[10][10];

};main(){

clrscr();

student s[5];int i,j,l,m,num;cout<<"How many student are in the class:";

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 27/400

cin>>num;

for(i=0;i<num;i++){

{cout<<"Enter roll number of student "<<"=";cin>>s[i].rno[i];}

cout<<"Enter a name:";

cin>>s[i].name[i];for(j=0;j<=4;j++){

cout<<"Enter a marks of student in subject "<<j+1<<"=";

cin>>s[i].marks[j];}

}cout<<"NAME\tROLL NO";

for(int k=0;k<=4;k++){cout<<" subject"<<k+1;

}

for(i=0;i<num;i++){

{cout<<"\n"<<s[i].name[i]<<"\t"<<s[i].rno[i];}

for(j=0;j<=4;j++)

cout<<"\t "<<s[i].marks[j];}

cout<<endl;getch();

}

#include<iostream.h>#include<conio.h>

void main(){

clrscr();float cel,faren;char choice;

cout<<"\n\n Enter a letter:";cin>>choice;

if(choice=='f')

{cout<<"\n\n Enter temperature in fahrenheit & convert it into celsius:";cin>>cel;cel=5.0/9.0*faren-32;

cout<<"Temperature in celcius is:"<<cel<<endl;}

elseif(choice=='c')

{cout<<"\n\n Enter temperature in celsuis & convert it into fahrenheit:";cin>>faren;faren=9.0/5.0*cel+32;

cout<<"\n\n Temperature in fahrenheit is:"<<faren;}

elsecout<<"\n\n Wrong Input:";getch();

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 28/400

}

#include<iostream.h>#include<conio.h>

struct student{

int rno[3];

float marks[3][3];char name[3][10];

};main()

{

clrscr();student s[3];

int i,j,k,l;for(i=0;i<=2;i++)

{cout<<"class detalis"<<i+1;

for(j=0;j<=2;j++)

{ {cout<<"\nEnter roll number of class "<<i+1<<" student "<<j+1<<"=";

cin>>s[i].rno[j];

cout<<"enter name of student "<<j+1<<" class "<<i+1<<"=";cin>>s[i].name[j];

}

for(k=0;k<=2;k++)

{

cout<<"Enter marks of class:"<<i+1<<"student "<<j+1<<"subject "<<k+1<<"=";cin>>s[i].marks[j][k];

}}

}clrscr();cout<<"\t\t*********OUTPUT*********\n";

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

{ cout<<"Class detals "<<i+1;

for(j=0;j<=2;j++){

{

cout<<"\nRoll no "<<s[i].rno[j];

cout<<"\nName is "<<s[i].name[j];}

for(k=0;k<=2;k++)

cout<<"Marks is in subject "<<k+1<<" "<<s[i].marks[j][k];

}

}getch();}

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 29/400

#include<iostream.h>

#include<conio.h>main()

{clrscr();

int a,b;

cout<<"Enter a decimal number:";cin>>a;while(a>=1){

 b=a%2;

a=a/2;cout<<b;

}getch();

}#include<iostream.h>

#include<conio.h>

class yahoo{

int no;

float salary; public:

yahoo(){cout<<"\n\nWELCOM TO CLASS";}

yahoo(int a,float b){int i;

cout<<"Enter a number";

cin>>i;no=a;

salary=b;}

void show()

{cout<<"\n\nNUMBER IS "<<no;

cout<<"\n\nSALARY "<<salary;

}};void main()

{

clrscr();yahoo y4;

yahoo y1(12,60500.50);yahoo (y1);

yahoo y2(y1);

yahoo y3(y2);y1.show();y2.show();

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 30/400

y3.show();

getch();

}#include<iostream.h>

#include<conio.h>

struct emp{float salary[5][5];char name[25][10];

};

main(){

clrscr();emp s[3];

int num,i,j,k,l;cout<<"how many emp are working in youer company";

cin>>num;

for(i=0;i<=2;i++){

for(k=0;k<=2;k++)

{cout<<"\nenter a detalis of company:";

for(j=0;j<num;j++)

{for(l=0;l<num;l++)

{

cout<<"name:";cin>>s[i][k].name[j];

cout<<"salayr";cin>>s[i][k].salary[j][l];

}}}}clrscr();cout<<"\n\n\n\n*******output********";

for(i=0;i<=2;i++){

for(k=0;k<=2;k++)

{cout<<"\n\nenter a detalis of company:";

for(j=0;j<num;j++)

{for(l=0;l<num;l++)

{cout<<"\nname "<<s[i][k].name[j];

cout<<"\nsalary "<<s[i][k].salary[j][l];

}}}}getch();}

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 31/400

#include<iostream.h>

#include<conio.h>main()

{ clrscr();float x;

cout<<endl;

cout<<"\t\t==================="<<endl;cout<<"\t\t|| MENU ||"<<endl;cout<<"\t\t|| [1]CONVERT ||"<<endl;cout<<"\t\t|| [2]SOLVE ||"<<endl;

cout<<"\t\t|| [3]EXIT ||"<<endl;

cout<<"\t\t==================="<<endl;cin>>x;

clrscr();float c;

if(x==1){ cout<<"\t\t#!*****************************!#"<<endl;

cout<<"\t\t#!#############################!#"<<endl;

cout<<"\t\t#![1]celsius to farenheit !#"<<endl;cout<<"\t\t#![2]farenheit to celsius !#"<<endl;

cout<<"\t\t#![3]farenheit to kelvin !#"<<endl;

cout<<"\t\t#![4]liter to gallons !#"<<endl;cout<<"\t\t#![5]miles to kilometers !#"<<endl;

cout<<"\t\t#![6]centimeters to meters !#"<<endl;cout<<"\t\t#![7]feet to meters !#"<<endl;

cout<<"\t\t#![8]horsepower to kilowatts !#"<<endl;cout<<"\t\t#![9]days to minutes !#"<<endl;

cout<<"\t\t#![10]pounds to kilograms !#"<<endl;

cout<<"\t\t#![11]centimeters to milemeters!#"<<endl;cout<<"\t\t#![12]milemeters to centimeters!#"<<endl;

cout<<"\t\t#![13]meters to centimeters !#"<<endl;cout<<"\t\t#![14]centimeters to meters !#"<<endl;

cout<<"\t\t#![15]centimeters to kelometers!#"<<endl;cout<<"\t\t#![16]centimeters to inch !#"<<endl;cout<<"\t\t#![17]centimeters to feet !#"<<endl;

cout<<"\t\t#![18]centimeters ti mile !#"<<endl;cout<<"\t\t#![19]meters to kelometers !#"<<endl;

cout<<"\t\t#![20]meters to inch !#"<<endl;

cout<<"\t\t#![21]meters to feet !#"<<endl;cout<<"\t\t#![22]meters to centimeters !#"<<endl;cout<<"\t\t#![23]meters to mile !#"<<endl;

cout<<"\t\t#![24]meters to milemeters !#"<<endl;

cout<<"\t\t#![11]go back to main menu !#"<<endl;cout<<"\t\t#![12]exit program !#"<<endl;

cout<<"\t\t#!#############################!#"<<endl;cout<<"\t\t#!*****************************!#"<<endl;

cin>>c;

float tc;if (c==1){

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 32/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 33/400

cin>>hp;

cout<<"horsepower in kilowatts is:"<<(hp*0.7457)<<endl;}float dys;

if(c==9){

cout<<"enter no. of days\n";

cin>>dys;cout<<"days in minute is:"<<((60*24)*dys)<<endl;

}float p;

if(c==10)

{cout<<"enter pounds\n";

cin>>p;cout<<"pounds in kilogram is:"<<(p*0.453592)<<endl;}}

elseif(x==2)

{

float s;cout<<"[1]Area of a rectangle\n";

cout<<"[2]Area of a triangle\n";

cout<<"[3]Circumference of a cirle\n";cout<<"[4]Volume of a cylinder\n";

cout<<"[5]Perimeter of a square\n";cout<<"[6]Acceleration\n";

cout<<"[7]Velocity\n";cout<<"[8]Voltage (given your resistance and current)\n";

cout<<"[9]Resistance (given your Voltage and current)\n";

cout<<"[10]Current (given your Voltage and resistance)\n";cout<<"[11]Go back to main menu\n";

cout<<"[12]Exit program\n";cin>>s;

float hr,w;if (s==1){

cout<<"enter height\n";cin>>hr;

cout<<"enter width\n";

cin>>w;cout<<"area is:"<<(hr*w)<<endl;

}

float b,ht;

if (s==2){

cout<<"enter base\n";cin>>b;cout<<"enter height\n";

cin>>ht;

cout<<"area is:"<<((b*ht)/2)<<endl;}float d,p=3.14;if (s==3)

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 34/400

{

cout<<"enter diameter\n";cin>>d;

cout<<"Circumference is:"<<(d*p)<<endl;}

float r,h,pc=3.14;

if (s==4){

cout<<"enter radius\n";cin>>r;

cout<<"enter height\n";

cin>>h;cout<<"Volume is:"<<(r*r*h*pc)<<endl;}

float ls;if (s==5)

{cout<<"enter lenght\n";

cin>>ls;

cout<<"perimeter is:"<<(ls*4)<<endl;}float f,m;

if (s==6)

{cout<<"enter netforce\n";

cin>>f;cout<<"enter mass\n";

cin>>m;cout<<"acceleration is:"<<(f/m)<<endl;}

float dv,t;

if (s==7){

cout<<"enter distance\n";cin>>dv;

cout<<"enter time\n";cin>>t;cout<<"Velocity is:"<<(dv/t)<<endl;

}float sr,sv;

if(s==10)

{cout<<"enter voltage\n";cin>>sv;

cout<<"enter resistance\n";

cin>>sr;cout<<"current is:"<<(sv/sr)<<endl;

}}else if 

(x==3)

{cout<<"to exit, press any key!!!";

}

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 35/400

getch();

}#include<iostream.h>

#include<conio.h>void tower()

{

int i , j , k , m;

for ( i=1; i<=5 ; i++ ){

for ( j=1; j<=38-i ; j++)

{cout <<" ";

}for ( k=1; k<=i; k++)

{cout <<"=";

}

for ( m=2; m<=i; m++){

cout<<"=";

}cout<<endl;

}for ( m=1; m<=20; m++)

{for ( j=1; j<=30; j++)

{

cout<<" ";}

for ( i=1; i<=15; i++)cout<<"=";

cout<<endl;

}

cout<<endl;}

void main()

{clrscr();cout<<"\n\n\t\t\t WELCOME TO TOWER \n\n";

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

tower();getch();

}#include<iostream.h>#include<conio.h>

main()

{clrscr();float runs[5],ball[5];int i;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 36/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 37/400

getch();

}#include<iostream.h>

#include<conio.h>void main()

{

int i , j , k , m;clrscr();for ( i=1; i<=8 ; i++ ){

For ( j=1; j<=38-i ; j++)

{cout <<" ";

}For ( k=1; k<=i; k++)

{Cout <<"*";

}

For ( m=2; m<=i; m++){

cout<<"*";

}cout<<endl;

}For ( m=1; m<=30; m++)

{For ( j=1; j<=30; j++)

{

cout<<" ";}

For ( i=1; i<=15; i++)cout<<"*";

cout<<endl;}cout<<endl;

getch();}

#include<iostream.h>

#include<conio.h>main(){

clrscr();

char name[50][50];double matches,runs[50][50],balls[50][50],sr[50][50],avg[50],temp[50][50]={0};

int i,j,pl;cout<<"ENTER NUMBER OF MATCHES PLAYED:";cin>>matches;

cout<<"HOW MANY PLAYER ARE PLAYED IN MATCHES:";

cin>>pl;for(i=0;i<matches;i++)

{

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 38/400

cout<<"Enter a data in match"<<i+1<<endl;

for(j=0;j<pl;j++){

cout<<"ENTER PLAYER NAME:";cin>>name[j];

cout<<"ENTER A BALLS PLAYED BY PLAYER "<<name[j]<<"=";

cin>>balls[i][j];cout<<"ENTER A RUN SCORED IN MATCH:"<<i+1<<"=";cin>>runs[i][j];}

}

cout<<"NAME\t\tRUNS\tBALLS\tSTRIKE RATE\tAVEREAGE"<<endl;for(i=0;i<matches;i++)

for(j=0;j<pl;j++){

sr[i][j]=(runs[i][j]/balls[i][j])*100;temp[i][j]=temp[i][j]+sr[i][j];

avg[j]=temp[i][j]/matches;

cout<<name[j]<<"\t\t"<<runs[i][j]<<"\t"<<balls[i][j]<<"\t"<<sr[i][j]<<"\t\t"<<avg[j]<<endl;}

getch();}

#include<iostream.h>#include<conio.h>

main()

{ int a[10][10],b[10][10],c[10][10],i,j,ra,ca,rb,cb;char choice;

do{ clrscr();

cout<<"\nINPUT ROW FOR MATRIX A: ";cin>>ra;cout<<"\nINPUT COLUMN FOR MATRIX A: ";

cin>>ca;cout<<"\nINPUT ROW FOR MATRIX B: ";

cin>>rb;

cout<<"\nINPUT COLUMN FOR MATRIX B: ";cin>>cb;if((ra==rb)&&(ca==cb))

{

cout<<"\nTHE TWO MATRICES CAN BE ADDED AS THEY ARE IDENTICAL.";cout<<"\n\nINPUT ELEMENTS FOR MATRIX A :\n";

for(i=0;i<ra;i++){cout<<"\n";

for(j=0;j<ca;j++)

cin>>a[i][j];}cout<<"\n\nINPUT ELEMENTS FOR MATRIX B :\n";

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 39/400

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

{cout<<"\n";

for(j=0;j<cb;j++)cin>>b[i][j];

}

for(i=0;i<ra;i++){for(j=0;j<ca;j++)c[i][j]=a[i][j]+b[i][j];

}

for(i=0;i<ra;i++){

cout<<"\n\n";for(j=0;j<ca;j++)

cout<<"\t"<<c[i][j];}

}

else{

cout<<"\nTHE TWO MATRICES CANNOT BE ADDED SINCE THEY ARE INIDENTICAL.";

cout<<"\nTHANK YOU.";}

cout<<"\n\nDO YOU WISH TO RE-EXECUTE THE PROGRAM?(Y/N) : ";cin>>choice;

}while(choice=='y'||choice=='Y');

getch();

}#include<iostream.h>

#include<conio.h>#include<math.h>

#include<process.h>int se,c=0;float hj,vj,h1,h2,x1,x2,u1,u2,d,sam,t1,t2;

void pass(void){

char waste;

char a[12]={"ballistics"};char b[12];int w=0;

for(w=0;w<3;w++)

{cout<<"enter password\n";

cin.getline(b,11);c=0;for(int i=0;i<11;i++)

{

if(a[i]!=b[i]){cout<<"\nwrong password\n";

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 40/400

c=25;

 break;}

elsec++;

}

if(w==1 && c==25)cout<<"\nlast try\n";if(c==i){

cout<<"\nWelcome to project BALLISTICS\nThis program enables easy";

cout<<" calculation of\nparameters related to ballistics\n\n";cout<<"They include following defence categories\n\n";

 break;}

}if(w==3&&c==25)

{

cout<<"programme closing due to security threat\n";E:cout<<"enter any character\n";

cin>>waste;

exit(0);}

}void select(void)

{cout<<"\t\tAPPLICATION \tCATEGORY NO\n\n";

cout<<"\t\taerial bombing\t\t1\n";

cout<<"\t\tmissile launching\t2\n";cout<<"\t\tanti-missile \t\t3\n";

cout<<"\t\tshell firing \t\t4\n";cout<<"\t\texit \t\t5\n";

}void select1(void){

cout<<endl;cout<<"This enables to calculate the required height or velocity of a jet\n";

cout<<"to hit a target at a given distance from it using a shell\n";

cout<<"The two cases are given below\n\n";cout<<"CASE NO:S\t\tTO FIND\t\tNEEDED DATA\n\n";cout<<"case no:1\t\theight \t\tdistance to target,velocity\n";

cout<<"case no:2\t\tvelocity \tdistance to target,height\n\n";

cout<<"case no:3\t\t\t\texit\n";cout<<"\n(to go to main menu enter 100 as case number)\n";

}void select2(void){

cout<<endl;

cout<<"This enables to find height or velocity of projection of a missile\n";cout<<"to attain the desired range. The two cases are given below\n";cout<<"choose the required by giving the case number\n\n";

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 41/400

cout<<"\t\tCASE NO:S\t\tTO FIND\t\tNEEDED DATA\n\n";

cout<<"\t\tcase no:1\t\theight \t\tvelocity,range\n";cout<<"\t\tcase no:2\t\tvelocity \theight,range\n\n";

cout<<"\t\tcase no:3\t\t\t\texit\n";cout<<"\n(to go to main menu enter 100 as case number)\n";

}

void select3(void){cout<<endl;cout<<"This enables to find height of projection of an anti-missile\n";

cout<<"Five cases are given below ,each with different set of input data\n";

cout<<"Please choose the required by entering method no:\n\n";cout<<"\t\tCASE NO:S\t\tNEEDED DATA\n\n";

cout<<"\t\tcase no:1\t\th2,t1,t2\n";cout<<"\t\tcase no:2\t\th2,x1,x2,u1,u2\n";

cout<<"\t\tcase no:3\t\th2,x1,s,u1,u2\n";cout<<"\t\tcase no:4\t\td,x1,s,u1,u2\n";

cout<<"\t\tcase no:5\t\th2,x1,d,u1,s\n\n";

cout<<"\t\tcase no:6\t\t\texit\n";cout<<"where,\nh2-height of enemies missile (in mts)\n";

cout<<"t2-time taken by enemies missile to reach point of collission (in s)\n";

cout<<"t1-time taken by anti-missile to reach point of collission (in s)\n";cout<<"u1-velocity of anti-missile (in m/s)\n";

cout<<"u2-velocity of missile (in m/s)\n";cout<<"x1-distance of point of collission from our launch pad (in mts)\n";

cout<<"x2-distance of point of collission from enemy's launch pad (in mts)\n";cout<<"s- distance b/w two launch pads (in mts)\n";

cout<<"d-distance of enemy's target from our launch pad\n";

cout<<"\n(to go to main menu enter 100 as case number)\n";}

void select4(void){

cout<<endl;cout<<"This helps to find the time or angle of projection of a shell\n";cout<<"which can hit a flying object at a specific height moving with\n";

cout<<"a specific average velocity (for specific velocity of projection)\n";cout<<"The two cases are given below, choose the required case\n\n";

cout<<"\t\tCASE NO:S\tTO FIND\t\t\t\tNEEDED DATA\n\n";

cout<<"\t\tcase no:1\ttime taken to reach target\tv,u,hs\n";cout<<"\t\tcase no:2\tangle of projection\t \tv,u,hs\n\n";cout<<"\t\tcase no:3\t\texit\n";

cout<<"where,\n";

cout<<"u-velocity of projection of shell\n";cout<<"v-velocity of flying object\n";

cout<<"h-height of flying object\n";cout<<"\n(to go to main menu enter 100 as case number)\n";}

float ar1(float xar1)

{if(se==1)cout<<"enter velocity of jet\n";

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 42/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 43/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 44/400

if(c!=25)

{m:select();

cout<<"enter the category no:\n";cin>>se;

if(se==1)

{select1();cout<<"enter case number\n";cin>>s1;

if(s1==100)

goto m;if(s1<1 || s1>3)

{cout<<"inalid entry\n";

goto l;}

if(s1==3)

goto l;cout<<"enter distance to target from jet (in mts)\n";

cin>>xj;

if(s1==1){

ar=ar1(xj);cout<<"REQUIRED HEIGHT="<<ar<<" mts"<<endl;

}if(s1==2)

{

ar=ar2(xj);cout<<"REQUIRED VELOCITY="<<ar<<" mts/s"<<endl;

}}

if(se==2){select2();

cout<<"enter case number\n";cin>>s2;

if(s2==100)

goto m;if(s2<1 || s2>3){

cout<<"invalid entry\n";

goto l;}

if(s2==3)goto l;cout<<"enter the range\n";

cin>>xm;

if(s2==1){m=ar1(xm);

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 45/400

cout<<"REQUIRED HEIGHT="<<m<<" mts"<<endl;

}if(s2==2)

{m=ar2(xm);

cout<<"REQUIRED VELOCITY="<<m<<" mts/s"<<endl;

}}if(se==3){

select3();

cout<<"method number\n";cin>>s3;

if(s3==100)goto m;

if(s3==1)h=am1();

if(s3==2)

h=am2();if(s3==3)

h=am3();

if(s3==4)h=am4();

if(s3==5)h=am5();

if(s3==6)goto l;

if(s3<1 || s3>6)

{cout<<"invalid entry\n";

goto l;}

cout<<"REQUIRED HEIGHT="<<h<<" mts\n";}if(se==4)

{select4();

cout<<"enter case number\n";

cin>>s4;if(s4==100)goto m;

if(s4<1 || s4>3)

{cout<<"invalid entry\n";

goto l;}if(s4==3)

goto l;

sh(s4);}if(se==5)

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 46/400

goto l;

if(se<1 || se>5){

cout<<"invalid entry\n";goto l;

}

}l:cout<<"do you want to continue (y/n)\n";cin>>rep;cin.get(ch);

}

getch();}

#include<iostream.h>#include<conio.h>

void main()

{

int n,i,prime,j;clrscr();

cout<<"enter limit";

cin>>n;for(i=1;i<=n;i++)

{for(j=2;j<=i/2;j++)

{ prime = 1;

if(i%j==0)

{ prime = 0;

 break;}}

if((prime==1)||(i==1)||(i==2)||(i==3))cout<<"\n"<<i;}

getch();}

#include<iostream.h>

#include<conio.h>struct player 

{

float ball[30],run[30],p_no[30];

char name[30][10];};

main(){clrscr();

 player match[10];

int m_num,p_num,i,j,k,l;cout<<"\nEnter a number of matches played:";cin>>m_num;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 47/400

cout<<"\nHow many player has been played in one match:";

cin>>p_num;for(i=0;i<m_num;i++)

{cout<<"\n\t||==========================================||";

cout<<"\n\t|| Enter detalis in Match "<<i+1<<" \t ||";

cout<<"\n\t||==========================================||";for(j=0;j<p_num;j++)

{ cout<<"\n\n\t**** Enter detalis of player "<<j+1<<" ****";{

cout<<"\n\nEnter player number:";

cin>>match[i].p_no[j];cout<<"\nEnter player name:";

cin>>match[i].name[j];}

for(k=0;k<m_num;k++){

cout<<"\nEnter a ball played in match "<<i+1<<" player "<<j+1<<":";

cin>>match[i].ball[k];cout<<"\nEnter a run score in match "<<i+1<<" player "<<j+1<<":";

cin>>match[i].run[k];

}}

}cout<<"\n\t\t*********OUTPUT********\n";

for(i=0;i<m_num;i++){ cout<<"\n\t||==========================================||";

cout<<"\n\t|| Match "<<i+1<<" detalis\t\t ||";

cout<<"\n\t||==========================================||";for(j=0;j<p_num;j++)

{cout<<"\n\n\t****Player "<<j+1<<" detalis****";

{cout<<"\n\nPlayer number:"<<match[i].p_no[j];cout<<"\nPlayer name:"<<match[i].name[j];

}for(k=0;k<m_num;k++)

{

cout<<"\nBall played in match "<<i+1<<" player "<<j+1<<":"<<match[i].ball[k];cout<<"\nRun score in match "<<i+1<<" player "<<j+1<<":"<<match[i].run[k];}

}

}getch();

}#include<iostream.h>#include<conio.h>

struct department

{char s_name[5][13];char f_name[5][10];

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 48/400

char c_name[5][10],class_name[10][10];

float sub_marks[10];int rno[10],total[10];

double obt_mark[10],per[10];};

struct gcuf 

{char dep_name[10][15];department s_data[5],marks[5];};

main()

{clrscr();

gcuf data[10];int a,b[10],c,d[30],e,f[10],g,h[10],i,j,k,l,m,n,o,p,q;

int num;cout<<"HOW MANY DEPARTMENT IN THE GCUF:";

cin>>num;

for(a=0;a<num;a++){

cout<<"\nENTER A DEPARTMENT NAME: ";

cin>>data[a].dep_name[a];cout<<"\nHOW MANY CLASSES IN "<<data[a].dep_name[a]<<" DEPARTMENT: ";

cin>>b[a];for(c=0;c<b[a];c++)

{cout<<"\nENTER A CLASS NAME ";

cin>>data[a].s_data[c].class_name[c];

cout<<"\nHOW MANY STUDENT IN "<<data[a].s_data[c].class_name[c];cin>>d[c];

cout<<"\nHOW MANY SUBJECT IN "<<data[a].s_data[c].class_name[c];cin>>f[c];

cout<<"\nENTER A TOTLA MARKS OF CLASS "<<data[a].s_data[c].class_name[c];cin>>data[a].s_data[c].total[c];for(e=0;e<d[c];e++)

{cout<<"\nENTER A ROLL NUMBER OF STUDENT "<<e+1<<"=";

cin>>data[a].s_data[c].rno[e];

cout<<"\nENTER NAME OF STUDENT "<<e+1<<": ";cin>>data[a].s_data[c].s_name[e];cout<<"\nENTER A FATHER NAME OF STUDNT "<<e+1<<": ";

cin>>data[a].s_data[c].f_name[e];

cout<<"\nENTER A CITY NAME OF STUDENT "<<e+1<<": ";cin>>data[a].s_data[c].c_name[e];

data[a].marks[e].obt_mark[e]=0;for(g=0;g<f[c];g++)cout<<"\nENTER A MARKS IN SUBJECT "<<g+1<<": ";

cin>>data[a].marks[e].sub_marks[g];

}}

}

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 49/400

 

for(a=0;a<num;a++)

{cout<<"\nDEPARTMENT NAME: "<<data[a].dep_name[a];}

for(c=0;c<b[a];c++)

{cout<<"\nCLASS NAME "<<data[a].s_data[c].class_name[c];for(e=0;e<d[c];e++){

cout<<"\nROLL NUMBER OF STUDENT "<<e+1<<"=";

cout<<data[a].s_data[c].rno[e];cout<<"\nNAME OF STUDENT "<<e+1<<": "<<data[a].s_data[c].s_name[e];

cout<<"\nFATHER NAME OF STUDNT "<<e+1<<": "<<data[a].s_data[c].f_name[e];cout<<"\nCITY NAME OF STUDENT "<<e+1<<": "<<data[a].s_data[c].c_name[e];

for(g=0;g<f[c];g++)cout<<"MARKS IN SUBJECT "<<g+1<<": "<<data[a].marks[e].sub_marks[g];

data[a].marks[e].obt_mark[e]+=data[a].marks[e].sub_marks[g];

data[a].marks[e].per[e]=(data[a].marks[e].obt_mark[e]/data[a].s_data[c].total[c])*100;{

if(data[a].marks[e].per[e]>=33 && data[a].marks[e].per[e]<=100)

if(data[a].marks[e].per[e]>=40)if(data[a].marks[e].per[e]>=50)

if(data[a].marks[e].per[e]>=60)if(data[a].marks[e].per[e]>=70)

if(data[a].marks[e].per[e]>=80)cout<<"\nstudent "<<e+1<<" Grade is A+:"<<endl;

else

cout<<"\nstudent "<<e+1<<" Grade is A:"<<endl;else

cout<<"\nstudent "<<e+1<<" Grade is B:"<<endl;else

cout<<"\nstudent "<<e+1<<" Grade is C:"<<endl;else

cout<<"\nstudent "<<e+1<<" Grade is D:"<<endl;

elsecout<<"\nstudent "<<e+1<<" Grade is E"<<endl;

else

cout<<"\nstudent "<<e+1<<" fail"<<endl;}

}

} }

getch();}

/******************************* SWITCH.CPP ***********************************

* Example comparing nested if's and switch statements 1998-10-01 ** Agner Fog ** *

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 50/400

* The nested if construction and the switch construction do exactly the same *

* thing, but the switch is easier to overview. ** *

******************************************************************************/#include <iostream.h>

#include <conio.h>

#include <math.h>

void main (){

float x = 2.83; int choise = 0;cout << "Enter your choise: 1=sin, 2=cos, 3=tan, 4=log ";

cin >> choise;

// nested if's:if (choise < 1 || choise > 4)

{

cout << "wrong choise";}

else

{ // choise is 1, 2, 3, or 4if (choise <= 2)

{ // choise is 1 or 2if (choise == 1)

{cout << sin(x);

}

else{ // choise is 2

cout << cos(x);}

}else{ // choise is 3 or 4

if (choise == 3){

cout << tan(x);

}else{ // choise is 4

cout << log(x);

}}

}cout << "\n";

// same with switch statement:

switch (choise){case 1:

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 51/400

cout << sin(x);

 break;case 2:

cout << cos(x); break;

case 3:

cout << tan(x); break;

case 4:cout << log(x);

 break;

default:cout << "wrong choise";

 break;}

getch();}

#include<iostream.h>

#include<conio.h>class A

{

int no;char name;

 public:void set1()

{no=10;

name='a';

}void put1()

{cout<<"number is "<<no;

cout<<"name is "<<name;}};

class B:public A

{

float salary; public:void set2()

{

A::set1();salary=444.4;

}void put2(){

A::put1();

cout<<"salary is "<<salary;}};

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 52/400

main()

{clrscr();

B a1;a1.set2();

a1.put2();

getch();}#include<iostream.h>#include<conio.h>

struct student

{int rno;

float marks;};

class dap{

student s1,s2;

 public:{ void fun(student ss,student se)

s1=ss;

s2=se;}

void show()

{cout<<"\n\n\noutput "<<s1;

}};

mian(){ clrscr();student ss1,student se1;

cout<<"\nenter 1 ";cin>>ss1.rno;

cin>>ss1.marks;

cout<<"\n\nenter 2 ";cin>>se1.rno;cin>>se1.marks;

dap d;d.fun(ss1,se1);

d.show();getch();

#include<iostream.h>

#include<conio.h>class numToword{

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 53/400

long int n;

int a[5],i; public :

void getData(){

cout<<"\n\n\nEnter an Integer : ";

cin>>n;}void putData(){

cout<<"\n\nYou entered (in words): \n\n\t\t";

if (n==0)calculate(n);

else //big else starts{

for(i=0;i<5;i++)a[i]=0;

i=4;

while(n>0){

a[i]=n%10;

n=n/10;i--;

}i++;

for(;i<5;i++) //big for starts{

if((i==0)&&(a[0]!=0))

{calculate((a[0]=a[0]*10+a[1]));

cout<<" Thousand ";i=2;

}else if((i==1)&&(a[1]!=0)){

calculate(a[1]);cout<<" Thousand ";

i=2;

}if((i==2)&&(a[2]!=0)){

calculate(a[2]);

cout<<" Hundred ";}

if( ((a[0]!=0)||(a[1]!=0)||(a[2]!=0)) && (a[3]!=0)){cout<<" and ";

i=3;

}else if(((a[0]!=0)||(a[1]!=0)||(a[2]!=0))&& (a[4]!=0)){

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 54/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 55/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 56/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 57/400

case 44:

cout<<" Forty-four "; break;

case 45:cout<<" Forty-five ";

 break;

case 46:cout<<" Forty-six ";

 break;case 47:

cout<<" Forty-seven ";

 break;case 48:

cout<<" Forty-eight "; break;

case 49:cout<<" Forty-nine ";

 break;

case 50:cout<<" Fifty ";

 break;

case 51:cout<<" Fifty-one ";

 break;case 52:

cout<<" Fifty-two "; break;

case 53:

cout<<" Fifty-three "; break;

case 54:cout<<" Fifty-four ";

 break;case 55:cout<<" Fifty-five ";

 break;case 56:

cout<<" Fifty-six ";

 break;case 57:cout<<" Fifty-seven ";

 break;

case 58:cout<<" Fifty-eight ";

 break;case 59:cout<<" Fifty-nine ";

 break;

case 60:cout<<" Sixty ";

 break;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 58/400

case 61:

cout<<" Sixty-one "; break;

case 62:cout<<" Sixty-two ";

 break;

case 63:cout<<" Sixty-three ";

 break;case 64:

cout<<" Sixty-four ";

 break;case 65:

cout<<" Sixty-five "; break;

case 66:cout<<" Sixty-six ";

 break;

case 67:cout<<" Sixty-seven ";

 break;

case 68:cout<<" Sixty-eight ";

 break;case 69:

cout<<" Sixty-nine "; break;

case 70:

cout<<" Seventy "; break;

case 71:cout<<" Seventy-one ";

 break;case 72:cout<<" Seventy-two ";

 break;case 73:

cout<<" Seventy-three ";

 break;case 74:cout<<" Seventy-four ";

 break;

case 75:cout<<" Seventy-five ";

 break;case 76:cout<<" Seventy-six ";

 break;

case 77:cout<<" Seventy-seven ";

 break;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 59/400

case 78:

cout<<" Seventy-eight "; break;

case 79:cout<<" Seventy-nine ";

 break;

case 80:cout<<" Eighty ";

 break;case 81:

cout<<" Eighty-one ";

 break;case 82:

cout<<" Eighty-two "; break;

case 83:cout<<" Eighty-three ";

 break;

case 84:cout<<" Eighty-four ";

 break;

case 85:cout<<" Eighty-five ";

 break;case 86:

cout<<" Eighty-six "; break;

case 87:

cout<<" Eighty-seven "; break;

case 88:cout<<" Eighty-eight ";

 break;case 89:cout<<" Eighty-nine ";

 break;case 90:

cout<<" Ninety ";

 break;case 91:cout<<" Ninety-one ";

 break;

case 92:cout<<" Ninety-two ";

 break;case 93:cout<<" Ninety-three ";

 break;

case 94:cout<<" Ninety-four ";

 break;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 60/400

case 95:

cout<<" Ninety-five "; break;

case 96:cout<<" Ninety-six ";

 break;

case 97:cout<<" Ninety-seven ";

 break;case 98:

cout<<" Ninety-eight ";

 break;case 99:

cout<<" Ninety-nine "; break;

default:cout<<"";

}

}};

void main()

{numToword obj;

clrscr();char rpl;

do{

obj.getData();

obj.putData();cout<<"\n\n Do you wish to continue ? (y/n) : ";

rpl=getch();

clrscr();

cout<<"\n\n\n\t\t*** Thanks for using this service. ***";cout<<"\n\n\n\t\t\t Designed by \n\t\t\t Muhammad Irfan Arshad";

cout<<" (www.irfangcu.webs.com) ";

}while(rpl=='y'||rpl=='Y');}

}

#include<iostream.h>#include<conio.h>

#include<iomanip.h>main(){

clrscr();

for(int a=1,s=20;a<=10;a+=2,s--){

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 61/400

cout<<setw(s);

for(int b=1;b<=a;b++)cout<<"*";

cout<<endl;}

for(int i=7,e=17;i>=1;i-=2,e--)

{cout<<setw(e);for(int j=1;j<=i;j++)

cout<<"*";

cout<<setw(e+=2);cout<<endl;

}getch();

}#include<iostream.h>

#include<conio.h>

main(){

clrscr();

for(int a=1;a<=7;a++){

int b=1;while(b<=a)

{cout<<"*"; b++;

}

cout<<"\n";}

getch();}

#include<iostream.h>#include<conio.h>main()

{clrscr();

int a=1,b=7;

do{a=b;

do

{cout<<"*";

a++;}while(a<=7);

cout<<endl;

 b--;}while(b>=1);

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 62/400

 

getch();}

#include<iostream.h>#include<conio.h>

main()

{clrscr();for(int a=1;a<=7;a++){

int b=7;

while(b>=a){cout<<"*";

 b--;}

cout<<"\n";}

getch();

}#include<iostream.h>

#include<conio.h>

main(){

clrscr();float total,obtained,avg,a;

total=1100;a=1;

do

{cout<<"Enter Your obtained marks :";

cin>>obtained;avg=(obtained/1100)*100;

if(avg>=70&&avg<=100)if(avg>=80)

{cout<<"grade is A+:";}else

{cout<<"grade is A:";}

elseif(avg>=50&&avg<70)if(avg>=60)

{cout<<"grade is B:";}

else{cout<<"grade is C:";}

elseif(avg>=33&&avg<50)if(avg>=40)

{cout<<"grade is D:";}

else{cout<<"grade is E:";}else

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 63/400

{cout<<"grade is F:";} }

while(a!=-1);getch();

}#include<iostream.h>

#include<conio.h>

main(){clrscr();int a=1,b=7;

do

{a=b;

do{

cout<<"*";a++;

}

while(a<=7);cout<<endl;

 b--;

}while(b>=1);

getch();

}#include<iostream.h>

#include<conio.h>

main(){

clrscr();int a=1;

do{cout<<a<<endl;

a++;}

while(a<=10);

getch();}#include<iostream.h>

#include<conio.h>

main(){

clrscr();int s,e;cout<<"Enter starting no:";

cin>>s;

cout<<"\n\n Enter ending no:";cin>>e;do

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 64/400

{

if(s%2!=0)cout<<s<<endl;

s++;}

while(s<=e);

getch();}#include<iostream.h>#include<conio.h>

main()

{clrscr();

int a=1,sum=0;do

{cout<<a<<endl;sum=sum+a;

a++; }

while(a<=5);

cout<<"result is:"<<sum;

getch();}

#include<iostream.h>#include<conio.h>

#include<math.h>main()

{

clrscr();int a;

a=1;do

{cout<<"a="<<a<<endl<<"square of a:"<<pow(a,2)<<"\t\t cube of a:"<<pow(a,3)<<endl;a++;

}while(a<=5);

getch();

}#include<iostream.h>#include<conio.h>

main()

{clrscr();

int tab,lenth,a=1;cout<<"Enter a table no:";cin>>tab;

cout<<"Enter a table lenth:";

cin>>lenth;do{

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 65/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 66/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 67/400

cout<<endl;

 j++;}

while(j<=6);getch();

}

#include<iostream.h>#include<conio.h>#include<iomanip.h>main()

{

clrscr();for(int a=1,s=7;a<=7;a++,s--)

{cout<<setw(s);for(int b=1;b<=a;b++)

cout<<"*";cout<<endl;

}

getch();}

#include<iostream.h>

#include<conio.h>main()

{clrscr();

int a,b,i,n=26,k,l,m;char ch;

for(i=1,m=65;i<=n;i++,m++)

{for(ch=65;ch<=m;ch++)

{cout<<ch;

}cout<<endl;}

getch();}

#include<iostream.h>

#include<conio.h>main(){

clrscr();

int n,c;long int sum;

sum=0;

cout<<"Enter a number:";

cin>>n;

for(c=1;c<=n;c++)

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 68/400

sum=sum+(c*c);

cout<<"result is:"<<sum;

getch();}

#include<iostream.h>

#include<conio.h>main(){clrscr();

float tab,len,a;

cout<<"Enter table no:";cin>>tab;

cout<<"Entr lenth of table:";cin>>len;

for(a=1;a<=len;a++)cout<<tab<<"*"<<a<<"="<<tab*a<<endl;

getch();

}#include<iostream.h>

#include<conio.h>

main(){

clrscr();int n,c;

long int sum;sum=0;

cout<<"Enter a number:";cin>>n;

for(c=1;c<=n;c++)

sum=sum+(c*c);

cout<<"result is:"<<sum;getch();

}

#include<iostream.h>#include<conio.h>main()

{

clrscr();int a,b;

cout<<"Input starting no:";cin>>a;cout<<"Input ending no:";

cin>>b;

for(a;a<=b;a++)if(a%2==0)cout<<a<<endl;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 69/400

getch();

}#include<iostream.h>

#include<conio.h>#include<math.h>

main()

{clrscr();int a;for(a=1;a<=5;a++)

cout<<"a="<<a<<endl<<"square of a="<<pow(a,2)<<endl;

getch();}

#include<iostream.h>#include<conio.h>

#include<math.h>main()

{

clrscr();int a,sum=0;

for(a=1;a<=5;a++){

cout<<a<<endl;sum=sum+a;

}cout<<"result is:"<<sum;

getch();

}#include<iostream.h>

#include<conio.h>#include<math.h>

main(){clrscr();

int c,mul=1;for(c=1;c<=10;c++)

{if(c%2!=0)mul=mul*c; }cout<<"result is"<<mul;

getch();}

#include<iostream.h>#include<conio.h>#include<math.h>

main()

{clrscr();int s,e;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 70/400

cout<<"Input Starting no:";

cin>>s;cout<<"Input ending no:";

cin>>e;for(s;s<=e;s++)

{

if(s%2==0)cout<<s<<endl;

}

getch();

}#include<iostream.h>

#include<conio.h>main()

{clrscr();

float a,b;

a=1;for(b=2;b<=100;b=b+2)

a=a+1/b;

cout<<"result is:"<<a;getch();

}#include<iostream.h>

#include<conio.h>main()

{

clrscr();int a=1;

for(;a<=5;){for(int b=5;b>=a;b--)

{cout<<"*";}

cout<<endl;

a++;}getch();

}

#include<iostream.h>#include<conio.h>main()

{

clrscr();for(int a=1;a<=7;a++)

{for(int j=1;j<=a;j++)cout<<"*";

cout<<"\n";}

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 71/400

getch();

}#include<iostream.h>

#include<conio.h>#include<iomanip.h>

main()

{clrscr();int a,b;for(a=1;a<=10;a++)

{

for(b=1;b<=a;b++)cout<<"*";

cout<<endl;}

for(int c=1;c<=9;c++){

for(int d=9;d>=c;d--)

cout<<"*";cout<<endl;}

int s,e,n;

for(s=1;s<=5;s++){for(e=1;e>=5-s;e--)

cout<<"*";for(n=1;n<=s;n++)

cout<<"*";cout<<endl;

}

getch();}

#include<iostream.h>#include<conio.h>

main(){clrscr();

int i=1;for(int a=4;a>=1;a--)

{

for(int b=5;b>i;b--)cout<<a<<"\t";cout<<endl;

i++;

}

getch();}#include<iostream.h>

#include<conio.h>

main(){clrscr();

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 72/400

int a;

a=1;while(a<=5)

{cout<<"pakistan"<<endl;

a++;

}getch();}#include<iostream.h>

#include<conio.h>

main(){

clrscr();int a=1;

while(a<=10){

cout<<a<<endl;

a++;}

getch();

}#include<iostream.h>

#include<conio.h>main()

{clrscr();

int i,j;

i=1;while(i<=7)

{ j=7;

while(j>=i){cout<<"*";

 j--;}

cout<<endl;

i++;}

getch();

}#include<iostream.h>

#include<conio.h>main(){

clrscr();

int a=1,sum=0;while(a<=5){cout<<a<<endl;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 73/400

sum=sum+a;

a++; }cout<<"result is:"<<sum;

getch();}

#include<iostream.h>

#include<conio.h>main(){clrscr();

int i,j;

i=1;while(i<=7)

{ j=1;

while(j<=i){cout<<"*";

 j++;}

cout<<endl;

i++;}

getch();

}#include<iostream.h>

#include<conio.h>

#include<math.h>main()

{clrscr();

int a;a=1;while(a<=5)

{cout<<"a="<<a<<endl<<"square of a:"<<pow(a,2)<<endl;

a++;

}getch();}

#include<iostream.h>

#include<conio.h>main()

{clrscr();int tab,a=1;

cout<<"Enter a table no:";

cin>>tab;while(a<=10){

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 74/400

cout<<tab<<"*"<<a<<"="<<tab*a<<endl;

a++;}

getch();}

#include<iostream.h>

#include<conio.h>main(){clrscr();

float a=1,b=2;

while(b<=100){

a=a+1/b; b=b+2;

}cout<<"result is :"<<a;

getch();

}#include<iostream.h>

#include<conio.h>

main(){

clrscr();int n;

while(n!=1){cout<<"Enter a any no:"<<endl;

cin>>n;

cout<<"you Enter:"<<n<<endl;}

cout<<"Program end:";

getch();}#include<iostream.h>

#include<conio.h>main()

{

clrscr();int a,b;a=1;

while(a<=7)

{ b=1;

while(b<=a){cout<<"*";

 b++;

}

cout<<endl;a++;}

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 75/400

getch();

}#include<iostream.h>

#include<conio.h>main()

{

clrscr();int a=10;while(a>=1){cout<<a<<endl;

a--;

}getch();

}#include<iostream.h>

#include<conio.h>main()

{

clrscr();int a=1,b;

while(a<=7)

{ b=1;

while(b<=a){

cout<<"*"; b++;

}

cout<<endl;a++;

}int i=1,j;

while(i<=6){

 j=6;

while(j>=i){

cout<<"*";

 j--;}cout<<endl;

i++;

}getch();

}#include<iostream.h>#include<conio.h>

main()

{clrscr();int a=4,b;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 76/400

while(a>=1)

{ b=4;

while(b>=1){cout<<a;

  b--; }

cout<<endl;a--;}getch();

}

C++ PROGRAMS COLLECTION

1. MY FIRST C++ PROGRAM 2. SUM OF TWO VALUE ENTER BY USER 

3. MTAH OPERATION (+,-,*,/) 4. COMPUND ASSIGNMENT OPERATIONS ON AS INTEGER 5. POSTFIX DECREMENT OPERATION 6. SQUARE OF ANY NO 7. DIFFERENCE OF POSTFIX & PREFIX INCREMENT OPERATOR 8. IF SLACTION STATEMENT  9. INPUT THREE NUMBER FIND WHICH IS MAXIMUM NUMBER 10.  GRADE CALCULATOR MULTI IF STRUCTURE 11.  WHETHER THE NO IS EVEN OR ODD FIND IT  

12. 

SALEPERSONS STATUS 13.  FIND THAT YOU ENTER A VOWEL 14.  PRINT HELLOW 10 TIME FOR LOOP 15.  ENTER ANY TABLE USING LOOP 16.  SQUARE AND CUBE OF ANY NO USING LOOP 17.  DISPLAY COUNTING 1 TO 10 USING LOOP 18.  STARIC PRINTING USING DO WHILE LOOP(1) 19.  STARIC PRINTING USING DO WHILE LOOP(2) 20.  STARIC PRINTING USING DO WHILE LOOP 

21. 

STARIC PRINTING USING WHILE LOOP 22.  DAIMAND STARIC PRINTING USING LOOP 23.  STARIC PRINTING USING LOOP 24.  SUM OF SQUARE OF THE INTEGERS FROM 1 TO N NUMNER 25.  CONSTANTS DECLARATION 26.  SIZE OF DATA TYPES 27.  EMPLOYEE DETAILS 

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 77/400

28.  SUM OF TWO NUMBERS 29.  DIFFERENCE BETWEEN TWO NUMBERS 30.  PRODUCT OF TWO NUMBERS 31.  DIVIDE A NUMBER WITH ANOTHER 

32. 

SQAURE OF A NUMBER 33.   AREA OF RECTANGLE 34.   AREA OF A TRIANGLE 35.  VOLUME OF A SPHERE 36.  CONVERT TEMPERATURE FROM KELVIN TO CELSIUS 37.  SIMPLE INTEREST  38.  PLAYER DETIALS 39.  SWAPPING INTEGERS 40.  CLASSIFY NUMBER OF DAYS IN YEARS, WEEKS AND DAYS 

41. 

TERNARY OPERATOR 42.  NESTED TERNARY OPERATOR 43.  FIND GREATER BETWEEN TWO NUMBERS 44.  FIND GREATER BETWEEN THREE NUMBERS 45.  FIND GREATEST AMONG THREE NUMBERS USING C LANGUAGE 46.  CONFIRM WHETHER LEAP YEAR OR NOT  47.  DISPLAY MONTH USING IF-ELSE CONSTRUCT  48.  SALARY OF A COMPUTER SALESMAN USING CONCEPT OF 

DEFINING VARIABLES WITH CONSTANT DATA 49.  SALARY FOR A NEW EMPLOYEE TO BE HIRED 50.  GIFT AGAINST BILL AMOUNT  51.  ROUNDING OFF NUMBERS TO TENS PLACE 52.  FIND ROOTS OF A QUADRATIC EQUATION 53.  DISPLAY MONTH USING SWITCH CASE 54.  DISPLAY MEANING OF GRADES WITH SWITCH CASE STRUCTURE 55.  SIMPLE CALCULATOR FOR TWO FRACTIONS 56.  PREDICT THE DAY ON WHICH A GIVEN DATE FALLS 57.  INCREMENT AND DECREMENT OPERATORS 58.  SAMPLE PROGRAM TO PRINT 1-100 USING FOR LOOP 59.  PRINT DIFFERENT PATTERNS 60.  COUNT POSITIVE AND NEGATIVE INPUTS IN TEN ENTRIES 61.  DETERMINE A PERFECT NUMBER 62.  DETERMINE A PRIME NUMBER  63.  PRINT A MULTIPLICATION TABLE USING DO-WHILE LOOP 64.  PRINT A MULTIPLICATION TABLE USING FOR LOOP 

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 78/400

65.  REVERSE OF A NUMBER 66.  DISPLAY SERIES : 1,2,3,4,5,6,7«««n 67.  DISPLAY SERIES :-1,4,-9,16,-25,36,-49,««...n 68.  DISPLAY SERIES : 0,2,5,9,14,20,27,35,44,54,65««««n 

69. 

DISPLAY SERIES : 2,6,12,20,30,42,56««««.n 70.  PRINT THE FIBONNACI SERIES: 1,2,3,5,8,13,21««««.n 71.   AVERAGE OF NUMBERS 72.  SUM OF SERIES WITH FIRST AND LAST TERM ENTERED BY USER 73.  SUM OF FRACTIONS SERIES: 1, 1/2, 1/3, 1/4 , 1/5,«««1/n 74.  FACTORS OF A NUMBER 75.  FACTORIAL OF A NUMBER 76.  SUM OF DIGITS IN A NUMBER 77.  COMPOUND INETERST BY SIMPLE INTEREST  

78. 

SIMPLE CALCULATOR FOR TWO FRACTIONS 79.  SUM OF ALL TERMS IN A ARRAY INPUT BY THE USER 80.   ACCEPT 10 NUMBERS AND PRINT THE SUM OF :

 ALL ODD ELEMNTS, EVEN ELEMENTS AND EVERY3RD 

ELEMENT SEPARATELY  

81.  FORM A NEW NUMBER FROM THREE DIGITS INPUT  82.  PRINT CONSUMER ELECTRICITY BILL AFTER DATA ENTRY  83.  EMPLOYEE PAY-SLIP 

84.  REVERSE A VECTOR 85.  FIND LARGEST AND SMALLEST ELEMNT IN A VECTOR 86.  DELETE DUPLICATE ELEMENTS FROM A VECTORsss 87.  PLAYER DETAILS USING ARRAYS 88.  WHITE SPACE CONFIRMATION 89.  CONFIRM PRESENCE OF A CHARACTER IN A STRING 90.  COUNT THE NUMBER OF VOWELS IN A STRING 91.  ENCRYPTION OF A STRING 92.  CONVERT A STRING INTO UPPERCASE 

93.  FIND SUBSTRING OF STRING 94.  FIND PATTERN STRING IN GIVEN MAIN STRING 95.  CONCATENATE TWO STRINGS 96.   ADDITION OF TWO MATRICES 97.  SUBTRACTION OF A MATRIX FROM ANOTHER 98.  MULTIPLICATION OF TWO MATRICES 99.  FIND ROWSUM AND COLUMNSUM IN A MATRIX 

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 79/400

100.  SUM OF ELEMENTS ABOVE AND BELOW THE MAIN DIAGONAL OF THE MATRIX 

101.  TRANSPOSE A MATRIX 102.  BINARY SEARCH 

103. 

BUBBLE SORT  104.  MERGE TWO GIVEN ARRAYS 105.  SORT TWO ARRAYS AND MERGE THEM 106.  TARNSFORM ARRAY : 58712496010 INTO : 97520146810 107.   ARRAY MANIPULATION 108.  CUBE OF A NUMBER USING FUNCTION 109.  PRINT THE LARGEST ELEMENT IN AN ARRAY USING FUNTION 110.  EFFECT OF INCREMENT AND DECREMENT OPERATORS USING 

FUNCTON 

111. 

PRINT PYRAMIDS OF DIGITS USING A FUNCTION 112.  FIND THE LEAST COMMON DIVISOR OF TWO NUMBERS USING A FUNCTION 

113.  TO FIND THE LCM AND HCF OF GIVEN 3 NUMBERS 114.  SUM OF N NATURAL NUMBERS FROM A GIVEN NUMBER USING 

 A FUNCTION 115.  ILLUSTRATE THE CALL BY VALUE METHOD FOR INVOKING A 

FUNCTION 116.  SHOW THE HANDICAP OF CALL BY VALUE METHOD 117.   A FUNCTION TO SHOW SPECIAL SERIES 118.  SWAP TWO VALUES USING CALL BY REFERENCE 119.  CONVERT DISTANCE IN FEET OR INCHES USING CALL BY  

REFERENCE METHOD 120.  TO SET THE LARGER VALUE OF TWO GIVEN VALUES TO 

(-1) USING CALL BY REFERENCE 

121.  FUNCTION TAKING NO ARGUMENTS AND RETURNING NO VALUES 

122.  TAKE TWO VALUES AND AN ARITHMETIC OPERATOR TO DISPLAY  

THE RESULT  123.  SORT AN INTEGER ARRAY USING FUNCTIONS 124.  DISPLAY STUDENTS MARKSHEET USING FUNCTIONS 125.  PALINDROME STRING OR NOT  126.  PRINT THE POSITION OF A CHARACTER IN A STRING USING 

FUNCTIONS 

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 80/400

127.  DETERMINE WHETHER TWO STRINGS CONTAIN EQUAL NUMBER OF CHARACTERS 

128.  CHECK WHETHER A CHARACTER IS ALPHANUMERIC OR NOT  129.  CHANGE THE CASE OF A CHARACTER 

130. 

COPY SMALLER STRING INTO BIGGER STRING 131.   APPEND THE FIRST STRING TO THE SECOND STRING 132.  TO JUSTIFY A STRING 133.  EMPLOYEE DATABASE 134.  HOTEL FOOD BILLING PROGRAM 135.  CONVERT DECIMAL NUMBER TO BINARY NUMBER 136.  CONVERT DECIMAL NUMBER TO OCTAL NUMBER 137.  CONVERT DECIMAL NUMBER TO HEXADECIMAL NUMBER 138.  CONVERT BINARY NUMBER TO DECIMAL NUMBER 

139. 

CONVERT BINARY NUMBER TO OCTAL NUMBER 140.  CONVERT BINARY NUMBER TO HEXADECIMAL NUMBER 141.  CONVERT OCTAL NUMBER TO DECIMAL NUMBER 142.  CONVERT OCTAL NUMBER TO BINARY NUMBER 143.  CONVERT OCTAL NUMBER TO HEXADECIMAL NUMBER 144.  CONVERT HEXADECIMAL NUMBER TO DECIMAL NUMBER 145.  CONVERT HEXADECIMAL NUMBER TO BINARY NUMBER 146.  CONVERT HEXADECIMAL NUMBER TO OCTAL NUMBER 147.  TRANSLATE NUMBER INTO WORDS 148.  CALENDAR OF A MONTH 149.  MY BEST PROGRAMS MENU 

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 81/400

 

My first C++ Program

#include<iostream.h>

#include<conio.h>

main()

{ clrscr();

cout<<"MY first C++ program:";

getch();

}

Sum of two value enter by user

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 82/400

#include<iostream.h>

#include<conio.h>

main()

{ clrscr();

cout <<"add any two No";

cout<<"\n\nASALAM-U-ALIKUM";

int a,b,ans;

cout<<"\n\ninput 1st value";

cin>>a;

cout<<"\n\ninput 2nd value";

cin>>b;

ans=a+b;

cout<<" ans:"<<ans;

cout<<"\n\n THANKS & ALLAH HAFIZ";

cout<<"\n\n HAVE A NOICE DAY";

getch();

}

Mtah operation (+,-,*,/)

#include<iostream.h>

#include<conio.h>

main()

{ clrscr();

cout<<"\n\nASALAM-U-ALIKUM";

cout<<"\n\n math operation";

int a,b,m,sub,div,add;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 83/400

cout<<"\n\nInput First value:";

cin>>a;

cout<<"\n\n Input secound value:";

cin>>b;

add=a+b;

sub=a-b;

m=a*b;

div=a/b;

cout<<"\n\n Result of add="<<add;

cout<<"\n\n Result is sub="<<sub;

cout<<"\n\n Result is multiplication="<<m;

cout<<"\n\n Result is divsion="<<div;

cout<<"\n\n THANKS & ALLAH HAFIZ";

cout<<"\n\n HAVE A NOICE DAY";

getch();

}

compund assignment operations on as intiger

#include<iostream.h>

#include<conio.h>

main()

{ clrscr();

cout<<"ASALAM-U-ALIKUM";

cout<<"\n\n compund assignment operations on as intiger";

int i;

i=10;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 84/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 85/400

b=4;

a=b--;

cout<<"\n\n a:"<<a;

cout<<"\n\n b:"<<b;

cout<<"\n\n THANKS & ALLAH HAFIZ";

cout<<"\n\n HAVE A NOICE DAY";

getch(); }

square of any No

#include<iostream.h>

#include<conio.h>

main()

{ clrscr();

cout<<"\n\n ASALAM-U-ALIKUM";

cout<<"\n\n square of any No:";

int sqr,num;

cout<<"\n\n Enter A number:";

cin>>num;

sqr=num*num;

cout<<"\n\n The square of "<<num<<"is"<<sqr;

cout<<"\n\n ALLAH HAFIZ & BYE BYE";

cout<<"\n\n HAVE A NOICE DAY";

getch();

}

difference of postfix & prefix increment operator

#include<iostream.h>

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 86/400

#include<conio.h>

main()

{ clrscr();

cout<<"\n\n ASALAM-U-ALIKUM";

cout<<"\n\n difference of postfix & prefix increment operator:";

int a,b,x,y;

a=b=x=y=0;

a++;

b=a++;

++x;

y=x++;

cout<<"\n\n a="<<a<<endl<<"b="<<b<<endl;

cout<<"\n\n x="<<x<<endl<<"y="<<y<<endl;

cout<<"ALLAH HAFIZ &BYE BYE";

getch();

}

If slaction statment

#include<iostream.h>

#include<conio.h>

main()

{ clrscr();

cout<<"ASALAM-U-ALIKUN";

cout<<"\n\n Input marks & display you have pased if the marks are 40 or more";

int marks;

cout<<"\n\n Enter your marks";

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 87/400

cin>>marks;

if(marks>=40)

cout<<"\n\n Cangratulatios! you have passed";

getch();

}

Input three number find which is maximum number

#include<iostream.h>

#include<conio.h>

main()

{ clrscr();

cout<<"ASALAM-U-ALIKUN";

cout<<":";

float a,b,c,max;

cout<<"\n\n Enter 1st Number:";

cin>>a;

cout<<"\n\n Enter 2nd Number:";

cin>>b;

cout<<"\n\n Enter 3rd Number:";

cin>>c;

max=a;

if(max<b)

max=b;

if(max<c)

max=c;

cout<<"\n\n The maximum No is:"<<max;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 88/400

cout<<"\n\n THANKS & BYE BYE";

getch();

}

Whether the No is Even or odd find it

#include<iostream.h>

#include<conio.h>

main()

{ clrscr();

cout<<"\n\n ASALAM-U-ALIKUM";

cout<<"\n\nWhether the No is Even or odd find it ";

int a;

cout<<"\n\n Enter any no";

cin>>a;

if(a%2==0)

cout<<"\n\n The No is Even:";

if(a%2!=0)

cout<<"\n\n The No is odd";

cout<<"\n\n THANKS & BYE BYE";

getch();

}

Grade calculator multi if structure

#include<iostream.h>

#include<conio.h>

main()

{ clrscr();

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 89/400

cout<<"\n\n ASALAM-U-ALIKUM";

cout<<"\n\n grade calculator ";

float per;

cout<<"\n\n Input your persantage:";

cin>>per;

if((per>=80)&&(per<=100))

cout<<"\n\n Grade is A++";

else

if((per>=70)&&(per<=79))

{

cout<<"\n\n Grade is A";

}

else

if((per>=60)&&(per<=69))

{

cout<<"\n\n Grade is B";

}

else

if((per>=50)&&(per<=59))

{

cout<<"\n\n Grade is C";

}

else

if((per>=40)&&(per<=49))

{

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 90/400

cout<<"\n\n Grade is D";

}

else

{

cout<<"\n\n you are Fail";

}

cout<<"\n\n THANKS & BYE BYE";

getch();

}

Salepersons status

#include<iostream.h>

#include<conio.h>

main()

{ clrscr();

cout<<"\n\n ASALAM-U-ALIKUM";

cout<<"\n\n Salepersons status ";

char status;

cout<<"\n\n enter a saleperson statuse:";

cin>>status;

if((status=='s')||(status=='S'))

{cout<<"\n\n senior salesperson is pad a Rs.400 a week";}

else if((status=='j')||(status=='J'))

{ cout<<"\n\n Junior salesperson is pad a rs.275 a week"; }

else

{ cout<<"\n\n you Input wrong value"; }

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 91/400

cout<<"\n\n THANKS & BYE BYE";

getch();

}

Find that you enter a vowel

#include<iostream.h>

#include<conio.h>

main()

{ clrscr();

char V;

cout<<"Enter an alphabet:";

cin>>V;

switch(V)

{

case 'a':

case 'A':

cout<<"You Entered vowel";break;

case 'e':

case 'E':

cout<<"You Entered vowel";break;

case 'i':

case 'I':

cout<<"You Entered vowel";break;

case 'o':

case 'O':

cout<<"You Entered vowel";break;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 92/400

case 'u':

case 'U':

cout<<"You Entered vowel";break;

default:

cout<<"Not vowel";

}

getch();

}

Print hellow 10 time for loop

#include<iostream.h>

#include<conio.h>

main()

{ clrscr();

int a;

for(a=1;a<=10;a++)

{

cout<<"hellow!"<<endl;}

getch();

}

Enter any table using loop

#include<iostream.h>

#include<conio.h>

main()

{ clrscr();

int tab,len;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 93/400

cout<<"enter any table no:";

cin>>tab;

cout<<"enter a lenth:";

cin>>len;

for(int a=1;a<=len;a++)

{cout<<tab<<"*"<<a<<"="<<tab*a<<endl;}

getch();

}

Square and Cube of any No using loop

#include<iostream.h>

#include<conio.h>

void main()

{ clrscr();

int num;

cout<<"enter a number:";

cin>>num;

for(int a=1;a<=num;a++)

{cout<<"\n a="<<a<<endl<<"the square of a:"<<a<<"*"<<a<<"="<<a*a<<endl;

cout<<"\t\t\t the cube of a:"<<a<<"*"<<a<<"*"<<a<<"="<<a*(a*a)<<endl;}

getch();

}

Display counting 1 to 10 using loop

#include<iostream.h>

#include<conio.h>

main()

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 94/400

{ clrscr();

int a=1;

do

{

cout<<a<<endl;

a++;

}

while(a<=10);

getch();

}

Staric printing using do while

*

* *

* * *

* * * *

* * * * *

* * * * * *

* * * * * * *

#include<iostream.h>

#include<conio.h>

main()

{

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 95/400

clrscr();

int a=1,b=7;

do

{

a=b;

do

{

cout<<"*";

a++;

}

while(a<=7);

cout<<endl;

b--;

}

while(b>=1);

getch();

}

Staric printing using do while loop(2)

* * * * * * *

* * * * * *

* * * * *

* * * *

* * *

* *

*

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 96/400

#include<iostream.h>

#include<conio.h>

main()

{

clrscr();

int a=1,b=1;

do

{

a=b;

do

{

cout<<"*";

a++;

}

while(a<=7);

cout<<endl;

b++;

}

while(b<=7);

getch();

}

Staric printing using do while loop

*

* *

* * *

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 97/400

* * * *

* * * * *

* * * *

* * *

* *

*

#include<iostream.h>

#include<conio.h>

main()

{

clrscr();

int a=1,b=5;

do

{

a=b;

do

{

cout<<"*";

a++;

}

while(a<=5);

cout<<endl;

b--;

}

while(b>=1);

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 98/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 99/400

#include<iostream.h>

#include<conio.h>

main()

{ clrscr();

int a=1,b;

while(a<=7)

{

b=1;

while(b<=a)

{

cout<<"*";

b++;

}

cout<<endl;

a++;

}

int i=1,j;

while(i<=6)

{

 j=6;

while(j>=i)

{

cout<<"*";

 j--;

}

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 100/400

cout<<endl;

i++;

}

getch();

}

Daimand staric printing using loop

*

* * *

* * * * *

* * * * * * *

* * * * * * * * *

* * * * * * *

* * * * *

* * *

*

#include<iostream.h>

#include<conio.h>

#include<iomanip.h>

main()

{ clrscr();

for(int a=1,s=20;a<=10;a+=2,s--)

{

cout<<setw(s);

for(int b=1;b<=a;b++)

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 101/400

cout<<"*";

cout<<endl;

}

for(int i=7,e=17;i>=1;i-=2,e--)

{

cout<<setw(e);

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

cout<<"*";

cout<<setw(e+=2);

cout<<endl;

}

getch();

}

Staric printing using loop

*

* *

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 102/400

* * *

* * * *

* * * * *

#include<iostream.h>

#include<conio.h>

#include<iomanip.h>

main()

{ clrscr();

for(int a=1,s=5;a<=5;a++,s--)

{ cout<<setw(s);

for(int b=1;b<=a;b++)

cout<<"*";

cout<<endl;}

getch();

}

Sum of square of the integers from 1 to n numner

#include<iostream.h>

#include<conio.h>

main()

{ clrscr();

int n,c;

long int sum;

sum=0;

cout<<"Enter a number:";

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 103/400

cin>>n;

for(c=1;c<=n;c++)

sum=sum+(c*c);

cout<<"result is:"<<sum;

getch();

}

CONSTANTS DECLARATION #include<iostream.h>

#include<conio.h>

void main()

{ int i;

char ch;

char str[34];

float f;

clrscr();

cout<<"ENTER AN INTEGER : ";

cin>>i;

cout<<"ENTER A CHARACTER : ";

cin>>ch;

cout<<"ENTER THE STRING : ";

cin>>str;

cout<<"ENTER A FLOAT : ";

cin>>f;

cout<<"\nCONSTANTS "<<endl;

cout<<"\nINTEGER : " <<i<<endl;

cout<<"\nCHARACTER : "<<ch<<endl;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 104/400

cout<<"\nSTRING : "<<str<<endl;

cout<<"\nFLOAT : " <<f<<endl;

getch();

}

OUTPUT

ENTER AN INTEGER: 7

ENTER A CHARACTER: R

ENTER THE STRING: RACHIT

ENTER A FLOAT: 6.3

CONSTANTS

INTEGER: 7

CHARACTER: R

STRING: RACHIT

FLOAT: 6.3

TO DISPLAY THE SIZE OF VARIOUS DATA TYPES AVAILABLE.

#include<iostream.h>

#include<conio.h>

Void main ()

{ int x=25;

clrscr ();

cout<<"sizeof(char)"; gotoxy(x,1);

cout<<sizeof(char)<<endl;

cout<<"sizeof(signed char)"; gotoxy(x,2);

cout<<sizeof(signed char)<<endl;

cout<<"sizeof(unsigned char)"; gotoxy(x,3);

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 105/400

cout<<sizeof(unsigned char)<<endl;

cout<<"sizeof(int)"; gotoxy(x,4);

cout<<sizeof(int)<<endl;

cout<<"sizeof(signed int)"; gotoxy(x,5);

cout<<sizeof(signed int)<<endl;

cout<<"sizeof(unsigned int)"; gotoxy(x,6);

cout<<sizeof(unsigned int)<<endl;

cout<<"sizeof(short)"; gotoxy(x,7);

cout<<sizeof(short)<<endl;

cout<<"sizeof(signed short)"; gotoxy(x,8);

cout<<sizeof(signed short)<<endl;

cout<<"sizeof(unsigned short)"; gotoxy(x,9);

cout<<sizeof(unsigned short)<<endl;

cout<<"sizeof(short int)"; gotoxy(x,10);

cout<<sizeof(short int)<<endl;

cout<<"sizeof(float)"; gotoxy(x,11);

cout<<sizeof(float)<<endl;

cout<<"sizeof(short float)"; gotoxy(x,12);

cout<<sizeof(short float)<<endl;

cout<<"sizeof(long)"; gotoxy(x,13);

cout<<sizeof(long)<<endl;

cout<<"sizeof(signed long)"; gotoxy(x,14);

cout<<sizeof(signed long)<<endl;

cout<<"sizeof(unsigned long)"; gotoxy(x,15);

cout<<sizeof(unsigned long)<<endl;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 106/400

cout<<"sizeof(long float)"; gotoxy(x,16);

cout<<sizeof(long float)<<endl;

cout<<"sizeof(double)"; gotoxy(x,17);

cout<<sizeof(double)<<endl;

cout<<"sizeof(long double)"; gotoxy(x,18);

cout<<sizeof(long double)<<endl;

getch ();}

OUTPUT

sizeof(char) 1

sizeof(signed char) 1

sizeof(unsigned char) 1

sizeof(int) 2

sizeof(signed int) 2

sizeof(unsigned int) 2

sizeof(short) 2

sizeof(signed short) 2

sizeof(unsigned short) 2

sizeof(short int) 2

sizeof(float) 4

sizeof(short float) 4

sizeof(long) 4

sizeof(signed long) 4

sizeof(unsigned long) 4

sizeof(long float) 8

sizeof(double) 8

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 107/400

sizeof(long double) 10

EMPLOYEES DETAILS 

#include<iostream.h>

#include<conio.h>

void main()

{ int eno;

char grade;

char name[25];

float comm;

clrscr();

cout<<"ENTER EMPLOYEE NAME : ";

cin.getline(name,25);

cout<<"\nENTER EMPLOYEE NUMBER : ";

cin>>eno;

cout<<"\nENTER EMPLOYEE GRADE : ";

cin>>grade;

cout<<"\nENTER EMPLOYEE COMMISION : ";

cin>> comm;

clrscr();

cout<< "EMPLOYEE DETAILS: "<<endl;

cout<< "EMPLOYEE NAME : " <<name<<endl;

cout<<"EMPLOYEE NUMBER : "<<eno<<endl;

cout<<"EMPLOYEE GRADE : "<<grade<<endl;

cout<<"EMPLOYEE COMMISSION : " <<comm<<endl;

getch();

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 108/400

}

OUTPUT

ENTER EMPLOYEE NAME : RAM AIRAN

ENTER EMPLOYEE NUMBER : 7

ENTER EMPLOYEE GRADE : A

ENTER EMPLOYEE COMMISION : 7000

EMPLOYEE DETAILS:

EMPLOYEE NAME : RAM AIRAN

EMPLOYEE NUMBER : 7

EMPLOYEE GRADE : A

EMPLOYEE COMMISSION : 7000

TO FIND THE SUM OF TWO NUMBERS 

#include<iostream.h>

#include<conio.h>

void main ()

{ int no1,no2,sum;

clrscr();

cout<<"ENTER FIRST NUMBER : ";

cin>>no1;

cout<<"ENTER SECOND NUMBER :";

cin>>no2;

sum=no1+no2;

cout<<"THE SUM OF TWO NUMBER : "<<sum;

getch();

}

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 109/400

OUTPUT

ENTER FIRST NUMBER : 25

ENTER SECOND NUMBER :18

THE SUM OF TWO NUMBERS : 43

TO FIND THE DIFFERENCE BETWEEN TWO NUMBERS 

#include<iostream.h>

#include<conio.h>

void main()

{ int no1,no2,difference;

clrscr();

cout<<"ENTER THE FIRST NUMBER : ";

cin>> no1;

cout<<"\nENTER THE SECOND NUMBER : ";

cin>>no2;

difference=no1-no2;

cout<<"\nTHE DIFFERENCE OF TWO NUMBERS IS : "<<difference;

getch();

}

OUTPUT

ENTER THE FIRST NUMBER : 63

ENTER THE SECOND NUMBER : 45

THE DIFFERENCE OF TWO NUMBERS IS : 18

TO DISPLAY PRODUCT OF TWO NUMBERS

#include<iostream.h>

#include<conio.h>

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 110/400

void main()

{ int num1, num2, prod;

clrscr();

cout<<"ENTER THE FIRST NUMBER : ";

cin >> num1;

cout<<"ENTER THE SECOND NUMBER : ";

cin>>num2;

prod=num1*num2;

cout<<"THE PRODUCT OF THE NUMBERS IS : " <<prod;

getch();

}

OUTPUT

ENTER THE FIRST NUMBER : 25

ENTER THE SECOND NUMBER : 18

THE PRODUCT OF THE NUMBERS IS : 450

TO DIVIDE A NUMBER WITH ANOTHER

#include<iostream.h>

#include<conio.h>

void main()

{ float quotient, remainder;

int no1,no2;

clrscr();

cout<<"\nENTER THE DIVIDEND : ";

cin>> no1;

cout<<"\nENTER THE DIVISOR : ";

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 111/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 112/400

THE SQUARE OF 18 is 324

ENTER A NUMBER : 25

THE SQUARE OF 25 is 625

TO FIND THE AREA OF RECTANGLE 

#include<iostream.h>

#include<conio.h>

void main()

{ float l,b,area;

clrscr();

cout<< "AREA OF RECT ";

cout<<"\n\nENTER LENGTH : ";

cin>> l;

cout<<"\nENTER BREADTH : ";

cin>> b;

area=l*b;

cout<<"\nTHE AREA OF THE RECTANGLE WITH GIVEN PARAMETERS IS : "<<area;

getch(); }

OUTPUT

AREA OF RECT

ENTER LENGTH: 12

ENTER BREADTH: 23

THE AREA OF THE RECTANGLE WITH GIVEN PARAMETERS IS : 276

AREA OF A TRIANGLE

#include<iostream.h>

#include<conio.h>

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 113/400

void main()

{ clrscr();

long float height, base, area;

cout<<"\nPLEASE ENTER THE HEIGHT FOR THE TRAINGLE : ";

cin>>height;

cout<<"\nPLEASE ENTER THE BASE FOR THE TRIANGLE : ";

cin>>base;

area=base*height*0.5;

cout<<"\nTHE AREA OF THE TRIANGLE IS : "<<area;

getch(); }

OUTPUT 

a)

PLEASE ENTER THE HEIGHT FOR THE TRAINGLE: 10

PLEASE ENTER THE BASE FOR THE TRIANGLE: 20

THE AREA OF THE TRIANGLE IS: 100

b)

PLEASE ENTER THE HEIGHT FOR THE TRAINGLE: 12

PLEASE ENTER THE BASE FOR THE TRIANGLE: 17

THE AREA OF THE TRIANGLE IS: 102

c)

PLEASE ENTER THE HEIGHT FOR THE TRAINGLE: 29

PLEASE ENTER THE BASE FOR THE TRIANGLE: 37

THE AREA OF THE TRIANGLE IS: 536.5

d)

PLEASE ENTER THE HEIGHT FOR THE TRAINGLE: 13

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 114/400

PLEASE ENTER THE BASE FOR THE TRIANGLE: 93

THE AREA OF THE TRIANGLE IS: 604.5

TO FIND THE VOLUME OF A SPHERE 

#include<iostream.h>

#include<conio.h>

void main()

{ float r,vol;

clrscr();

cout<< "VOLUME OF A SPHERE";

cout<<"\n\nENTER RADIUS : ";

cin>> r;

vol=((4/3)*(22/7)*r*r*r);

cout<<"\nTHE VOLUME OF THE SPHERE WITH GIVEN PARAMETERS IS : "<<vol;

getch();

}

OUTPUT

VOLUME OF A SPHERE

ENTER RADIUS : 7

THE VOLUME OF THE SPHERE WITH GIVEN PARAMETERS IS: 1432.4366

TO FIND THE TEMPERATURE IN CELSIUS FROM KELVIN 

#include<iostream.h>

#include<conio.h>

void main()

{ int a,c;

clrscr();

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 115/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 116/400

PLAYER DETAILS

#include<iostream.h>

#include<conio.h>

void main()

{ clrscr();

float runs1, runs2, runs3, runs4, runs5, balls1, balls2, balls3, balls4, balls5;

long double sr1, sr2, sr3, sr4, sr5, avgsr; char name[30];

cout <<"\nENTER PLAYER NAME : ";

cin.getline(name,30);

cout<<"\nENTER RUNS SCORED IN MATCH 1: ";

cin>>runs1;

cout<<"\nENTER BALLS PLAYED BY PLAYER IN MATCH 1: ";

cin >> balls1;

sr1=(runs1*100)/balls1;

cout<<"\nENTER RUNS SCORED IN MATCH 2: ";

cin>>runs2;

cout<<"\nENTER BALLS PLAYED BY PLAYER IN MATCH 2: ";

cin >> balls2;

sr2=(runs2*100)/balls2;

cout<<"\nENTER RUNS SCORED IN MATCH 3: ";

cin>>runs3;

cout<<"\nENTER BALLS PLAYED BY PLAYER IN MATCH 3: ";

cin >> balls3;

sr3=(runs3*100)/balls3;

cout<<"\nENTER RUNS SCORED IN MATCH 4: ";

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 117/400

cin>>runs4;

cout<<"\nENTER BALLS PLAYED BY PLAYER IN MATCH 4: ";

cin >> balls4;

sr4=(runs4*100)/balls4;

cout<<"\nENTER RUNS SCORED IN MATCH 5: ";

cin>>runs5;

cout<<"\nENTER BALLS PLAYED BY PLAYER IN MATCH 5: ";

cin >> balls5;

sr5=(runs5*100)/balls5;

avgsr=(sr1+sr2+sr3+sr4+sr5)/5;

clrscr();

cout<<"\nPLAYER NAME : "<< name <<endl;

cout<<"\nRUNS SCORED IN MATCH1 : "<< runs1 <<endl;

cout<<"\nBALLS PLAYED IN MATCH1 : "<< balls1<<endl;

cout<<"\nMATCH1 STRIKE RATE : " << sr1<<endl;

cout<<"\nRUNS SCORED IN MATCH2 : "<< runs2 <<endl;

cout<<"\nBALLS PLAYED IN MATCH2 : "<< balls2<<endl;

cout<<"\nMATCH2 STRIKE RATE : " << sr2<<endl;

cout<<"\nRUNS SCORED IN MATCH3 : "<< runs3 <<endl;

cout<<"\nBALLS PLAYED IN MATCH3 : "<< balls3<<endl;

cout<<"\nMATCH3 STRIKE RATE : " << sr3<<endl;

cout<<"\nRUNS SCORED IN MATCH4 : "<< runs4 <<endl;

cout<<"\nBALLS PLAYED IN MATCH4 : "<< balls4<<endl;

cout<<"\nMATCH4 STRIKE RATE : " << sr4<<endl;

cout<<"\nRUNS SCORED IN MATCH5 : "<< runs5 <<endl;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 118/400

cout<<"\nBALLS PLAYED IN MATCH5 : "<< balls5<<endl;

cout<<"\nMATCH5 STRIKE RATE : " << sr5<<endl;

cout<<"\nAVERAGE STRIKE RATE : " <<avgsr<<endl;

getch();

}

OUTPUT

ENTER PLAYER NAME : RAHUL DRAVID

ENTER RUNS SCORED IN MATCH 1: 87

ENTER BALLS PLAYED BY PLAYER IN MATCH 1: 95

ENTER RUNS SCORED IN MATCH 2: 99

ENTER BALLS PLAYED BY PLAYER IN MATCH 2: 112

ENTER RUNS SCORED IN MATCH 3: 76

ENTER BALLS PLAYED BY PLAYER IN MATCH 3: 65

ENTER RUNS SCORED IN MATCH 4: 51

ENTER BALLS PLAYED BY PLAYER IN MATCH 4: 23

ENTER RUNS SCORED IN MATCH 5: 124

ENTER BALLS PLAYED BY PLAYER IN MATCH 5: 157

PLAYER NAME : RAHUL DRAVID

RUNS SCORED IN MATCH1 : 87

BALLS PLAYED IN MATCH1 : 95

MATCH1 STRIKE RATE : 91.578947

RUNS SCORED IN MATCH2 : 99

BALLS PLAYED IN MATCH2 : 112

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 119/400

MATCH2 STRIKE RATE : 88.392857

RUNS SCORED IN MATCH3 : 76

BALLS PLAYED IN MATCH3 : 65

MATCH3 STRIKE RATE : 116.923077

RUNS SCORED IN MATCH4 : 51

BALLS PLAYED IN MATCH4 : 23

MATCH4 STRIKE RATE : 221.73913

RUNS SCORED IN MATCH5 : 124

BALLS PLAYED IN MATCH5 : 157

MATCH5 STRIKE RATE : 78.980892

AVERAGE STRIKE RATE : 119.522981

SWAPPING INTEGERS

#include<iostream.h>

#include<conio.h>

void main()

{ int a, b, c;

clrscr();

cout<<"\aENTER A : ";

cin>>a;

cout<<"\aENTER B : ";

cin>>b;

c=a;

a=b;

b=c;

cout<<"\n\aNEW A= \a"<<a;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 120/400

cout<<"\n\aNEW B= \a"<<b;

getch();

}

*OUTPUT

ENTER A : 23

ENTER B : 34

NEW A= 34

NEW B= 23

CLASSIFY THE TOTAL NUMBER OF DAYS INPUT INTO YEAR,WEEK AND DAYS: 

#include<iostream.h>

#include<conio.h>

void main()

{ long num, temp, days, week, year;

char ch;

do

{

clrscr();

cout<<"ENTER THE TOTAL NUMBER OF DAYS : ";

cin>>num;

year=num/365;

temp=num%365;

week=temp/7;

days=temp%7;

cout<<"\n"<<year<<" years " << week << " weeks " << days << " days.";

cout<<"\n\nRepeat? (y/n) : ";

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 121/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 122/400

#include<conio.h>

void main()

{ int count=0;

int num1=7, num2=4;

clrscr();

count=(num1<num2)?num1:num2;

cout<<count;

getch();

}

OUTPUT

NESTED TERNARY OPERATOR 

#include<iostream.h>

#include<conio.h>

void main()

{ int count=0;

int num1=2;

clrscr();

count=(num1<0)?-1:(num1>0)?7:9;

cout<<count;

getch();

}

OUTPUT

7

FIND THE GREATER OF TWO GIVEN NUMBERS

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 123/400

#include<iostream.h>

#include<conio.h>

void main()

{ int num1, num2;

clrscr ();

cout << "PLEASE ENTER THE FIRST NUMBER : ";

cin >> num1;

cout << "PLEASE ENTER THE SECOND NUMBER : ";

cin >> num2;

if (num1>num2)

{ cout << "1st NUMBER IS GREATER.";}

else

{ cout << "2nd NUMBER IS GREATER."; }

getch ();

}

OUTPUT

PLEASE ENTER THE FIRST NUMBER : 787

PLEASE ENTER THE SECOND NUMBER : 657

1st NUMBER IS GREATER.

PLEASE ENTER THE FIRST NUMBER : 874

PLEASE ENTER THE SECOND NUMBER : 897

2nd NUMBER IS GREATER.

GREATER OF THREE NUMBERS

#include<iostream.h>

#include<conio.h>

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 124/400

void main()

{ int a, b, c;

clrscr();

cout<<"ENTER NUMBER1 : ";

cin>>a;

cout<<"ENTER NUMBER2 : ";

cin>>b;

cout<<"ENTER NUMBER3 : ";

cin>>c;

if(a>b && a>c && b>c)

{ cout<<a<<" IS GREATEST."<<endl;

cout<<b<<" IS SECOND GREATEST."<<endl;

cout<<c<<" IS LEAST."; }

else if(a>b && a>c && c>b)

{ cout<<a<<" IS GREATEST."<<endl;

cout<<c<<" IS SECOND GREATEST."<<endl;

cout<<b<<" IS LEAST."; }

else if(b>a && b>c && a>c)

{ cout<<b<<" IS GREATEST."<<endl;

cout<<a<<" IS SECOND GREATEST."<<endl;

cout<<c<<" IS LEAST."; }

else if(a>b && a>c && c>a)

{ cout<<b<<" IS GREATEST."<<endl;

cout<<c<<" IS SECOND GREATEST."<<endl;

cout<<a<<" IS LEAST."; }

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 125/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 126/400

ENTER NUMBER1 : 45

ENTER NUMBER2 : 34

ENTER NUMBER3 : 32

45 IS GREATEST.

34 IS SECOND GREATEST.

32 IS LEAST.

TO FIND IF A YEAR INPUT IS LEAP OR NOT #include<iostream.h>

#include<conio.h>

void main ()

{ clrscr ();

int year;

cout << "ENTER A YEAR : ";

cin >> year;

if(year%400==0 || (year%4==0 && year%100!=0))

{ cout << "IT IS A LEAP YEAR."; }

else

{ cout << "IT IS NOT A LEAP YEAR"; }

getch ();

}

OUTPUT

ENTER A YEAR : 2004

IT IS A LEAP YEAR.

ENTER A YEAR : 2003

IT IS NOT A LEAP YEAR

DISPLAY MONTH CORRESPONDING TO INPUT, USING IF-ELSE CONSTRUCT

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 127/400

#include<iostream.h>

#include<conio.h>

void main()

{ clrscr();

int n;

cout<<"ENTER A NUMBER LESS THAN OR EQUAL TO 12 : ";

cin>>n;

while(n>12||n<1)

{

cout<<"\nINVALID ENTRY. PLEASE RE-ENTER YOUR CHOICE : ";

cin>>n;

}

if(n==1)

cout<<n<<" IMPLIES JANUARY.";

else if(n==2)

cout<<n<<" IMPLIES FEBRUARY.";

else if(n==3)

cout<<n<<" IMPLIES MARCH.";

else if(n==4)

cout<<n<<" IMPLIES APRIL.";

else if(n==5)

cout<<n<<" IMPLIES MAY.";

else if(n==6)

cout<<n<<" IMPLIES JUNE.";

else if(n==7)

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 128/400

cout<<n<<" IMPLIES JULY.";

else if(n==8)

cout<<n<<" IMPLIES AUGUST.";

else if(n==9)

cout<<n<<" IMPLIES SEPTEMBER.";

else if(n==10)

cout<<n<<" IMPLIES OCTOBER.";

else if(n==11)

cout<<n<<" IMPLIES NOVEMBER.";

else if(n==12)

cout<<n<<" IMPLIES DECEMBER.";

getch();

}

OUTPUT

ENTER A NUMBER LESS THAN OR EQUAL TO 12 : 11

11 IMPLIES NOVEMBER.

ENTER A NUMBER LESS THAN OR EQUAL TO 12 : 6

6 IMPLIES JUNE.

ENTER A NUMBER LESS THAN OR EQUAL TO 12 : 8

8 IMPLIES AUGUST.

ENTER A NUMBER LESS THAN OR EQUAL TO 12 : 9

9 IMPLIES SEPTEMBER.

ENTER A NUMBER LESS THAN OR EQUAL TO 12 : 12

12 IMPLIES DECEMBER.

ENTER A NUMBER LESS THAN OR EQUAL TO 12 : 3

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 129/400

3 IMPLIES MARCH.

SALARY OF THE COMPUTER SALESMAN WITH CONCEPT OF DEFINING THE BASIC SALARY AS

CONSTANT 

#include<iostream.h>

#include<conio.h>

#define basic 1500

void main()

{ long bonus;

long float commision, salary, comp_no, comp_cost, sales;

char name[25], choice;

do

{

clrscr();

cout<<"\nPLEASE ENTER THE NAME : ";

cin>>name;

cout<<"\nPLEASE ENTER THE NUMBER OF COMPUTERS SOLD : ";

cin>>comp_no;

cout<<"\nPLEASE ENTER THE COST OF 1 COMPUTER : ";

cin>>comp_cost;

sales=comp_no*comp_cost;

bonus=comp_no*200;

commision=(sales*2)/100;

salary=bonus+commision+basic;

cout<<"\t\t\t\t*S.J. COMPUTERS*\n";

cout<<"\n\nTOTAL SALES OF S.J. COMPUTERS : "<<sales;

cout<<"\n\nBASIC SALARY OF " << name << " : " << basic;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 130/400

cout<<"\n\nCOMMISION OF " << name << " : " << commision;

cout<<"\n\nBONUS OF " << name << " : " << bonus;

cout<<"\n\nNET SALARY OF " << name << " : " << salary;

cout<<"\n\nPRESS Y TO REPEAT ELSE EXIT PRESSING ANY KEY : ";

cin>>choice;

}

while(choice=='y'||choice=='Y');

getch();

}

OUTPUT

PLEASE ENTER THE NAME : Rachit

PLEASE ENTER THE NUMBER OF COMPUTERS SOLD : 25

PLEASE ENTER THE COST OF 1 COMPUTER : 30000

*S.J. COMPUTERS*

TOTAL SALES OF S.J. COMPUTERS : 750000

BASIC SALARY OF Rachit : 1500

COMMISION OF Rachit : 15000

BONUS OF Rachit : 5000

NET SALARY OF Rachit : 21500

PRESS Y TO REPEAT ELSE EXIT PRESSING ANY KEY : N

SALARY FOR AN EMPLOYEE TO BE HIRED FOR A JOB 

#include<iostream.h>

#include<conio.h>

void main()

{ float age, sal;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 131/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 132/400

{

if(age>=28 && age<=35)

cout<<"MR. " << name << " YOUR SALARY IS : 4000";

else

cout<<"SORRY !! YOU ARE NOT ELIGIBLE FOR THE JOB.";

}

cout<<"\nDO YOU WANT TO CONTINUE? (y/n) : ";

cin>>choice;

}

while(choice=='y'||choice=='Y');

}

OUTPUT

a)

ENTER NAME : Rachit

FRESHER OR EXPERIENCED? (F/E) : f 

ENTER AGE : 34

MR. Rachit YOUR SALARY IS : 4000

DO YOU WANT TO CONTINUE? (y/n) : y

b)

ENTER NAME : Rachit

FRESHER OR EXPERIENCED? (F/E) : f 

ENTER AGE : 27

SORRY !! YOU ARE NOT ELIGIBLE FOR THE JOB.

DO YOU WANT TO CONTINUE? (y/n) : y

c)

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 133/400

ENTER NAME : rachit

FRESHER OR EXPERIENCED? (F/E) : f 

ENTER AGE : 35

SORRY !! YOU ARE NOT ELIGIBLE FOR THE JOB.

DO YOU WANT TO CONTINUE? (y/n) : n

d)

ENTER NAME : Rachit

FRESHER OR EXPERIENCED? (F/E) : e

ENTER AGE : 30

MR. Rachit YOUR SALARY IS : 7000

DO YOU WANT TO CONTINUE? (y/n) : y

e)

ENTER NAME : Rachit

FRESHER OR EXPERIENCED? (F/E): e

ENTER AGE : 37

MR. Rachit YOUR SALARY IS : 10000

DO YOU WANT TO CONTINUE? (y/n) : y

f)

ENTER NAME : Rachit

FRESHER OR EXPERIENCED? (F/E) : e

ENTER AGE : 28

SORRY !! YOU ARE NOT ELIGIBLE FOR THE JOB.

DO YOU WANT TO CONTINUE? (y/n) : n

GIFT AGAINST BILL AMOUNT

#include<iostream.h>

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 134/400

#include<conio.h>

void main()

{ clrscr();

float bill, amt;

cout<<"\t\t\t**SJ supermarket**";

cout<<"\n\nWELCOME DEAR CUSTOMER!!!";

cout<<"\n\nENTER BILL NUMBER : ";

cin>>bill;

cout<<"\nENTER AMOUNT OF BILL : ";

cin>>amt;

cout<<"\t\t\t**SJ supermarket**";

if(amt<100 && amt>0)

cout<<"\n\nSORRY, NO GIFT FOR YOU.";

else if(amt>=100 && amt<500)

cout<<"\n\n\nTHANK YOU FOR SHOPPING FROM OUR STORE.\

\nSURPRISE!! A GIFT FOR YOU!!\nCONGRATULATIONS!! YOU WIN A CALCULATOR";

else if(amt>=500 && amt<1000)

cout<<"\n\n\nTHANK YOU FOR SHOPPING FROM OUR STORE.\

\nSURPRISE!! A GIFT FOR YOU!!\nCONGRATULATIONS!! YOU WIN A RADIO.";

else if(amt>=1000)

cout<<"\n\n\nTHANK YOU FOR SHOPPING FROM OUR STORE.\

\nSURPRISE!!A GIFT FOR YOU!!\nCONGRATULATIONS!! YOU WIN OXFORD ATLAS";

else if(amt>=3000)

cout<<"\n\n\nTHANK YOU FOR SHOPPING FROM OUR STORE.\

\nSURPRISE!!A GIFT FOR YOU!!\

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 135/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 136/400

b=a+10;

if(n%10<5)

cout<<"\n"<<n<<" WHEN ROUNDED OFF = "<<a;

else if(n%10>=5)

cout<<"\n"<<n<<" WHEN ROUNDED OFF = "<<b;

getch();

}

*OUTPUT

ENTER THE NUMBER TO BE ROUNDED OFF : 18

18 WHEN ROUNDED OFF = 20

ENTER THE NUMBER TO BE ROUNDED OFF : 25

25 WHEN ROUNDED OFF = 30

TO FIND THE ROOTS OF A QUADRATIC EQUATION

#include<iostream.h>

#include<conio.h>

#include<math.h>

#include<process.h>

void main()

{ float a,b,c,root1,root2,delta;

char choice;

do

{

clrscr();

cout<<"ENTER THE VALUES FOR THE VARIABLESIN EQUATION : ax^2 + bx + c :";

cout<<"\nENTER a : ";

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 137/400

cin>>a;

cout<<"\nENTER b : ";

cin>>b;

cout<<"\nENTER c : ";

cin>>c;

if(!a)

{

cout<<"\nINVALID ENTRY FOR a.";

exit(0);

}

delta=(b*b)-(4*a*c);

if(delta<0)

cout<<"\nIMAGINARY AND COMPLEX ROOTS.";

else if (delta>0)

{

root1=(-b+sqrt(delta))/(2*a);

root2=(-b-sqrt(delta))/(2*a);

cout<<"\nROOTS ARE REAL AND UNEQUAL."<<endl;

cout<<"\nROOTS ARE : " << root1 << "\t" <<root2;

}

else if(delta==0)

{

root1=(-b/(2*a));

root2=root1;

cout<<"\nROOTS ARE REAL AND EQUAL."<<endl;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 138/400

cout<<"\nROOTS ARE : " << root1 << "\t" <<root2;

}

cout<<"\n\nDO YOU WANT TO CONTINUE (Y/N) : ";

cin>>choice;

}

while(choice=='y'||choice=='Y');

getch();

}

OUTPUT

ENTER THE VALUES FOR THE VARIABLESIN EQUATION : ax^2 + bx + c :

ENTER a : 3

ENTER b : 5

ENTER c : 2

ROOTS ARE REAL AND UNEQUAL.

ROOTS ARE : -0.666667 -1

DO YOU WANT TO CONTINUE (Y/N) : n

/ MONTH DISPLAY USING SWITCH

#include<iostream.h>

#include<conio.h>

void main()

{

int m;

clrscr();

cout<<"ENTER A NUMBER : ";

cin>>m;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 139/400

while(m>12||m<1)

{

cout<<"INVALID ENTRY. RE-ENTER YOUR CHOICE : ";

cin>>m;

}

switch(m)

{

case 1 : cout<<"JANUARY"; break;

case 2 : cout<<"FEBRUARY"; break;

case 3 : cout<<"MARCH"; break;

case 4 : cout<<"APRIL"; break;

case 5 : cout<<"MAY"; break;

case 6 : cout<<"JUNE"; break;

case 7 : cout<<"JULY"; break;

case 8 : cout<<"AUGUST"; break;

case 9 : cout<<"SEPTEMBER"; break;

case 10 : cout<<"OCTOBER"; break;

case 11 : cout<<"NOVEMBER"; break;

case 12 : cout<<"DECEMBER"; break;

}

getch();

}

OUTPUT

ENTER A NUMBER : 11

NOVEMBER

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 140/400

ENTER A NUMBER : 6

JUNE

ENTER A NUMBER : 8

AUGUST

ENTER A NUMBER : 9

SEPTEMBER

ENTER A NUMBER : 3

MARCH

DISPLAY MEANING OF GRADES USING SWICH CASE STRUCTURE

#include<iostream.h>

#include<conio.h>

void main()

{

clrscr();

char ch;

cout<<"ENTER GRADE : ";

cin>>ch;

switch(ch)

{

case 'a':

case 'A':

cout<<"\nEXCELLENT"<<endl; break;

case 'b':

case 'B':

cout<<"\nGOOD"<<endl; break;

case 'c':

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 141/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 142/400

void main()

{ float num1,num2,den1,den2,result; char sign, choice;

do

{

clrscr();

cout<<"FRACTION 1 : "<<endl;

cout<<"\nENTER THE NUMERATOR : "; cin>>num1;

cout<<"\nENTER THE DENOMINATOR : "; cin>>den1;

cout<<"\nENTER THE CALCULATION OPERATOR (+, -, *, /) : ";

cin>>sign;

cout<<"\nFRACTION 2 : "<<endl;

cout<<"\nENTER THE NUMERATOR : "; cin>>num2;

cout<<"\nENTER THE DENOMINATOR : "; cin>>den2;

if(num1==0 || num2==0 || den1==0 || den2==0)

{ cout<<"\nOOPS!!! INVALID ENTRY. BYE! "; exit(0); }

switch(sign)

{ case '+': result=((num1/den1)+(num2/den2)); break;

case '-': result=((num1/den1)-(num2/den2)); break;

case '*': result=((num1/den1)*(num2/den2)); break;

case '/': result=((num1/den1)/(num2/den2)); break;

default :

cout<<"\nOOPS!!!INVALID CALCULATION OPERATOR. BYE!!";

exit(0);

}

cout<<"\nRESULT IS : "<<result;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 143/400

cout<<"\n\nDO YOU WISH TO RE-EXECUTE THE PROGRAM? (Y/N) : ";

cin>>choice;

}

while(choice=='y'||choice=='Y');

getch();

}

OUTPUT

FRACTION 1 :

ENTER THE NUMERATOR : 12

ENTER THE DENOMINATOR : 23

ENTER THE CALCULATION OPERATOR (+, -, *, /) : *

FRACTION 2 :

ENTER THE NUMERATOR : 12

ENTER THE DENOMINATOR : 23

RESULT IS : 0.272212

DO YOU WISH TO RE-EXECUTE THE PROGRAM? (Y/N) : n

PREDICT THE DAY ON WHICH A GIVEN DATE FALLS

#include<iostream.h>

#include<conio.h>

void main()

{ long x, num, date, month, year, julian, fours, hundreds, four_hundreds, day;char choice;

do

{ clrscr();

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 144/400

cout << "WELCOME! \n\n\nTHE PROGRAM GUESSES THE DAY ON WHICH A GIVEN DATE

OCCURS.\n\nHERE THE BIRTH DAY SHALL BE GUESSED AS AN EXAMPLE." << endl;

cout << "\n\nENTER YOUR BIRTH DATE : ";

cin>>num;

date=num/1000000;

year=num%10000;

x=num%1000000;

month=x/10000;

if ((year%100!=0 && year%4==0) || year%400==0)

ulian=366;

else

ulian=365;

switch(month)

{

case 1: julian -= 0;

case 2: julian -= 31;

case 3: if ( (year%100!=0 && year%4==0) || year%400==0)

 julian -= 29;

else

 julian -= 28;

case 4: julian -= 31;

case 5: julian -= 30;

case 6: julian -= 31;

case 7: julian -= 30;

case 8: julian -= 31;

case 9: julian -= 31;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 145/400

case 10: julian -= 30;

case 11: julian -= 31;

case 12: julian -= 30;

}

ulian+=date;

fours=(year-1)/4;

hundreds=(year-1)/100;

four_hundreds=(year-1)/400;

day=(year+julian+fours-hundreds+four_hundreds)%7;

cout<<"\nTHE BITHDAY IS ON : ";

if(day==0)

cout<<"SATURDAY";

else if (day==1)

cout<<"SUNDAY";

else if (day==2)

cout<<"MONDAY";

else if (day==3)

cout<<"TUESDAY";

else if (day==4)

cout<<"WEDNESDAY";

else if (day==5)

cout<<"THURSDAY";

else

cout<<"FRIDAY";

cout << "\n\nWOULD YOU LIKE TO CONTINUE WITH MORE DATES? (y/n) : ";

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 146/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 147/400

18 is assigned to a,b,c and d :

++a = 19

--b = 17

c++ = 18

d-- = 18

a = 19

b = 17

c = 19

d = 17

A SAMPLE PROGRAM TO PRINT 1-100

#include<iostream.h>

#include<conio.h>

void main ()

{ int num;

clrscr();

for (num=1; num<=100; num ++)

{ cout <<num<<"\t"; }

getch ();

}

OUTPUT

1 2 3 4 5 6 7 8 9 10

11 12 13 14 15 16 17 18 19 20

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 148/400

21 22 23 24 25 26 27 28 29 30

31 32 33 34 35 36 37 38 39 40

41 42 43 44 45 46 47 48 49 50

51 52 53 54 55 56 57 58 59 60

61 62 63 64 65 66 67 68 69 70

71 72 73 74 75 76 77 78 79 80

81 82 83 84 85 86 87 88 89 90

91 92 93 94 95 96 97 98 99 100

STAR PATTERN 1

#include<iostream.h>

#include<conio.h>

void main()

{ int count,i;

clrscr();

for(count=0;count<=10;count++)

{

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

cout<<'*';

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 149/400

cout<<endl;

}

getch();

}

Output

**

***

****

*****

******

*******

********

*********

**********

***********

STAR PATTERN 2

#include<iostream.h>

#include<conio.h>

void main()

{

int count,i;

clrscr();

for(count=10;count>=0;count--)

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 150/400

{

for(i=count;i>=0;i--)

cout<<'*';

cout<<endl;

}

getch();

}

OUTPUT

**********

*********

********

*******

******

*****

****

***

**

*

STAR PATTERN 3 

#include<iostream.h>

#include<conio.h>

void main()

{ int count,i, n=10;

clrscr();

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

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 151/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 152/400

void main()

{ int count,i, n=10;

clrscr();

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

{

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

{

cout<<" ";

}

for(int j=10; j>count;j--)

{

cout<<"*";

}

cout<<endl;

}

getch();

}

Output

**********

*********

********

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 153/400

*******

******

*****

****

***

**

*

/ALPHABETS PATTERN 1

#include<iostream.h>

#include<conio.h>

void main()

{ clrscr ();

int count,i,n=26,k,j,m;

char ch;

for(i=1, m=65;i<=n;i++,m++)

{

for(k=1;k<=n-i;k++)

{ cout<<" "; }

for(ch=65;ch<=m;ch++)

{

cout<<ch;

}

cout<<endl;

}

getch();

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 154/400

}

ALPHABETS PATTERN 2 

#include<iostream.h>

#include<conio.h>

void main()

{ clrscr ();

int count,i,n=26,k,j,m;

char ch;

for(i=1, m=65;i<=n;i++,m++) // for line

{

for(k=1;k<=n-i;k++) // for white space

{ cout<<" "; }

for(ch=65;ch<=m;ch++) // for elements in line

{ cout<<ch << " "; }

cout<<endl;

}

getch();

}

COUNT POSITIVE AND NEGATIVE INPUTS IN TEN ENTRIES

#include<iostream.h>

#include<conio.h>

void main ()

{

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 155/400

int count=0, pcount=0, ncount=0, num;

clrscr ();

cout<<"\nENTER 10 NUMBER :\n";

for (count=0; count<10; count=count+1)

{

cin >> num;

if (num>0)

pcount=pcount+1;

else

ncount=ncount+1;

}

cout << "THE NUMBER OF POSITIVE INTEGERS : " << pcount << endl;

cout << "THE NUMBER OF NEGATIVE INTEGERS : " << ncount;

getch ();

}

OUTPUT

ENTER 10 NUMBER :

123

34

56

5

-54

-43

453

-45

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 156/400

-3

-89

THE NUMBER OF POSITIVE INTEGERS : 5

THE NUMBER OF NEGATIVE INTEGERS : 5

TO DETERMINE A PERFECT NUMBER.

#include<iostream.h>

#include<conio.h>

void main ()

{ int num, fact, gfact, fsum=0;

clrscr ();

cout << "ENTER A NUMBER : ";

cin >> num;

gfact=(num/2)+1;

for (fact=1; fact<=gfact; fact=fact+1)

{

if (num%fact==0)

fsum+=fact;

}

if (fsum==num)

cout << "\nIT IS A PERFECT NUMBER. " << endl;

else

cout << "\nIT IS NOT A PERFECT NUMBER. " << endl;

getch ();

}

OUTPUT

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 157/400

ENTER A NUMBER : 6

IT IS A PERFECT NUMBER.

ENTER A NUMBER : 25

IT IS NOT A PERFECT NUMBER.

TO DETERMINE A PRIME NUMBER.

#include<iostream.h>

#include<conio.h>

void main ()

{ long num, fact; int count;

clrscr ();

cout << "ENTER A NUMBER : ";

cin >> num;

for ( fact=1, count=0; fact<=num/2; fact=fact+1)

{

if (num%fact==0)

count=count+1;

}

if (count==1)

cout << "\nYES! ITS IS A PRIME NUMBER." << endl;

else

cout << "\nNO! IT IS NOT A PRIME NUMBER." << endl;

getch ();

}

OUTPUT

ENTER A NUMBER : 3

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 158/400

YES! ITS IS A PRIME NUMBER.

ENTER A NUMBER : 23

YES! ITS IS A PRIME NUMBER.

ENTER A NUMBER : 9

NO! IT IS NOT A PRIME NUMBER.

PRINT THE MULTIPLES OF A NUMBER USING A DO-WHILE LOOP;

#include<iostream.h>

#include<conio.h>

void main()

{ int num, multi=0;

clrscr();

cout<<"\nPLEASE ENTER THE NUMBER : ";

cin>>num;

cout<<"\nTHE MULTIPLES OF " <<num <<" are : " <<endl << endl;

do

{

multi++;

cout <<num << " X " << multi << " = " << num*multi << endl;

} while(multi<10);

getch();

}

Output

a)

PLEASE ENTER THE NUMBER : 63

THE MULTIPLES OF 63 are :

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 159/400

63 X 1 = 63

63 X 2 = 126

63 X 3 = 189

63 X 4 = 252

63 X 5 = 315

63 X 6 = 378

63 X 7 = 441

63 X 8 = 504

63 X 9 = 567

63 X 10 = 630

b)

PLEASE ENTER THE NUMBER : 1539

THE MULTIPLES OF 1539 are :

1539 X 1 = 1539

1539 X 2 = 3078

1539 X 3 = 4617

1539 X 4 = 6156

1539 X 5 = 7695

1539 X 6 = 9234

1539 X 7 = 10773

1539 X 8 = 12312

1539 X 9 = 13851

1539 X 10 = 15390

PRINT THE MULTIPLICATION TABLE OF A NUMBER USING A FOR LOOP;

#include<iostream.h>

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 160/400

#include<conio.h>

void main()

{ int num, multi;

clrscr();

cout<<"\nPLEASE ENTER THE NUMBER : ";

cin>>num;

cout<<"\nTHE MULTIPLES OF " <<num <<" are : " <<endl << endl;

for(multi=1; multi<=10; multi++)

{ cout<< num<<" X " <<multi << " = " << num*multi <<endl; }

getch();

}

Output

a)

PLEASE ENTER THE NUMBER : 81

THE MULTIPLES OF 81 are :

81 X 1 = 81

81 X 2 = 162

81 X 3 = 243

81 X 4 = 324

81 X 5 = 405

81 X 6 = 486

81 X 7 = 567

81 X 8 = 648

81 X 9 = 729

81 X 10 = 810

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 161/400

b)

PLEASE ENTER THE NUMBER : 2745

THE MULTIPLES OF 2745 are :

2745 X 1 = 2745

2745 X 2 = 5490

2745 X 3 = 8235

2745 X 4 = 10980

2745 X 5 = 13725

2745 X 6 = 16470

2745 X 7 = 19215

2745 X 8 = 21960

2745 X 9 = 24705

2745 X 10 = 27450

REVERSE OF A NUMBER INPUT THE USER

#include<iostream.h>

#include<conio.h>

void main()

{ char choice;

do

{

long num,reverse=0, count, t1;

clrscr();

cout<<"\nENTER A NUMBER : ";

cin>>num;

while (num != 0)

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 162/400

{

t1=num%10;

reverse=(reverse*10)+t1;

num=num/10;

}

cout<<"\nTHE REVERSE NUMBER IS : "<<reverse<<endl;

cout<<"\nREPEAT THE PROGRAM? (y/n) : ";

cin>>choice;

}while(choice=='y'||choice=='Y');

}

OUTPUT

a)

ENTER A NUMBER : 63

THE REVERSE NUMBER IS : 36

REPEAT THE PROGRAM? (y/n) : y

b)

ENTER A NUMBER : 854556

THE REVERSE NUMBER IS : 655458

REPEAT THE PROGRAM? (y/n) : y

c)

ENTER A NUMBER : 38978231

THE REVERSE NUMBER IS : 13287983

REPEAT THE PROGRAM? (y/n) : y

d)

ENTER A NUMBER : 4352496

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 163/400

THE REVERSE NUMBER IS : 6942534

REPEAT THE PROGRAM? (y/n) : n

A PROGRAM TO DISPLAY AN ARITHMETIC PROGRESSION : 1 , 2 , 3 , 4 , 5 ,.....N

#include<iostream.h>

#include<conio.h>

void main()

{ long double i, n;

clrscr();

cout<<"\nEnter the number of elements for the series : ";

cin>>n;

gotoxy(1,4);

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

cout<<i<<"\t";

getch();

}

Output

a)

Enter the number of elements for the series : 15

1 2 3 4 5 6 7 8 9 10

11 12 13 14 15

b)

Enter the number of elements for the series : 30

1 2 3 4 5 6 7 8 9 10

11 12 13 14 15 16 17 18 19 20

21 22 23 24 25 26 27 28 29 30

c)

Enter the number of elements for the series : 81

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 164/400

1 2 3 4 5 6 7 8 9 10

11 12 13 14 15 16 17 18 19 20

21 22 23 24 25 26 27 28 29 30

31 32 33 34 35 36 37 38 39 40

41 42 43 44 45 46 47 48 49 5051 52 53 54 55 56 57 58 59 60

61 62 63 64 65 66 67 68 69 70

71 72 73 74 75 76 77 78 79 80

81

PRINT THE SERIES : -1, +4, -9, +16....N

#include<iostream.h>

#include<conio.h>

void main()

{ clrscr();

int num, even, odd, sum, count1, count2, temp1=1, temp2;

cout<<"Enter the number of elements : ";

cin>>num;

cout<<"\n";

for(count1=1,count2=2;temp1<=num/2;count1+=2,count2+=2,temp1++)

{

even=count2*count2;

odd=count1*count1;

temp2=odd-(2*odd);

cout<<temp2<<"\t";

cout<<even<<"\t";

}

if(num%2!=0)

{

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 165/400

odd=count1*count1;

temp2=odd-(2*odd);

cout<<temp2;

}

getch();

}

Output

a)

Enter the number of elements : 10

-1 4 -9 16 -25 36 -49 64 -81 100

b)

Enter the number of elements : 34

-1 4 -9 16 -25 36 -49 64 -81 100

-121 144 -169 196 -225 256 -289 324 -361 400

-441 484 -529 576 -625 676 -729 784 -841 900

-961 1024 -1089 1156

c)

Enter the number of elements : 63

-1 4 -9 16 -25 36 -49 64 -81 100

-121 144 -169 196 -225 256 -289 324 -361 400

-441 484 -529 576 -625 676 -729 784 -841 900

-961 1024 -1089 1156 -1225 1296 -1369 1444 -1521 1600

-1681 1764 -1849 1936 -2025 2116 -2209 2304 -2401 2500

-2601 2704 -2809 2916 -3025 3136 -3249 3364 -3481 3600

-3721 3844 -3969

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 166/400

A SERIES WITH 2 APS : 0,2,5,9,14,20,27,35....N

#include<iostream.h>

#include<conio.h>

void main()

{ clrscr();

int n,i,sum;

cout<<"Enter the nth term : ";

cin>>n;

cout<<"\n";

for(i=2, sum=0; i<=n;i++)

{

cout<<sum << "\t" ;

sum+=i;

}

cout<<sum;

getch();

}

Output

a)

Enter the nth term : 7

0 2 5 9 14 20 27

b)

Enter the nth term : 18

0 2 5 9 14 20 27 35 44 54

65 77 90 104 119 135 152 170

c)

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 167/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 168/400

sum+=i;

}

getch();

}

Output

a)

Enter the number of terms : 9

0 2 6 12 20 30 42 56 72

b)

Enter the number of terms : 15

0 2 6 12 20 30 42 56 72 90

110 132 156 182 210

c)

Enter the number of terms : 24

0 2 6 12 20 30 42 56 72 90

110 132 156 182 210 240 272 306 342 380

420 462 506 552

d)

Enter the number of terms : 43

0 2 6 12 20 30 42 56 72 90

110 132 156 182 210 240 272 306 342 380

420 462 506 552 600 650 702 756 812 870930 992 1056 1122 1190 1260 1332 1406 1482 1560

1640 1722 1806

e)

Enter the number of terms : 63

0 2 6 12 20 30 42 56 72 90

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 169/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 170/400

cout<<"\n\nREPEAT THE SAME PROGRAM? (Y/N) : ";

cin>>choice;

}while(choice=='y'||choice=='Y');

}

Output

a)

ENTER THE NUMBER OF ELEMENTS REQUIRED : 8

0 1 1 2 3 5 8 13

REPEAT THE SAME PROGRAM? (Y/N) : y

b)

ENTER THE NUMBER OF ELEMENTS REQUIRED : 36

0 1 1 2 3 5 8 13 21 34

55 89 144 233 377 610 987 1597 2584 4181

6765 10946 17711 28657 46368 75025 121393 196418 317811 514229

832040 1346269 2178309 3524578 5702887 9227465

REPEAT THE SAME PROGRAM? (Y/N) : y

c)

ENTER THE NUMBER OF ELEMENTS REQUIRED : 28

0 1 1 2 3 5 8 13 21 34

55 89 144 233 377 610 987 1597 2584 4181

6765 10946 17711 28657 46368 75025 121393 196418

REPEAT THE SAME PROGRAM? (Y/N) : N

AVERAGE OF N NUMBERS

#include<iostream.h>

#include<conio.h>

void main()

{ long float result ;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 171/400

long num,n, sum=0, count=0;

clrscr();

cout << "\nENTER THE NUMBER OF TERMS : ";

cin >> n;

for(count=0;count<n;sum+=num,count++)

{

cout<<"\nENTER A TERM : ";

cin>>num;

}

result=sum/n;

cout<<"\nTHE AVERAGE OF NUMBERS IS " << result;

getch(); }

OUTPUT

ENTER THE NUMBER OF TERMS : 15

ENTER A TERM : 231

ENTER A TERM : 324

ENTER A TERM : 456

ENTER A TERM : 675

ENTER A TERM : 768

ENTER A TERM : 6

ENTER A TERM : 4566

ENTER A TERM : 87876

ENTER A TERM : 546

ENTER A TERM : 7457

ENTER A TERM : 5646

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 172/400

ENTER A TERM : 675

ENTER A TERM : 4356

ENTER A TERM : 6758

ENTER A TERM : 54678

THE AVERAGE OF NUMBERS IS 11667

SUM OF AN ARITHMETIC PROGRESSION WHOSE FIRST TERM AND LAST TERMS ARE

ENTERED BY THE USER AND THE COMMON DIFFERENCE IS 1 */

#include<iostream.h>

#include<conio.h>

void main()

{ long double first, last, sum ; char choice;

do

{

clrscr();

cout<<"\n\nPLEASE ENTER THE FIRST TERM :";

cin>>first;

cout<<"\n\nPLEASE ENTER THE LAST TERM :";

cin>>last;

for(sum=0;first<=last;first++)

sum=sum+first;

cout<< "\n\n THE FINAL SUM IS : " << sum;

cout<<"\n\nPRESS Y TO REPEAT ELSE EXIT PRESSING ANY KEY : ";

cin>>choice;

}

while(choice=='y' || choice=='Y');

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 173/400

cout<<"\n\n PROGRAM EXCLUSIVELY CODED BY MUHAMMAD IRFAN ARSHAD OF CLASS 11. \n\\n ANY

MODIFICATION DONE HERBY INVITE LEGAL ACTION.\n\nSUGGESTIONS AND COMMENTS WELCOME AT

chand4202002@yahoo.com";

getch();

}

OUTPUT

a)

PLEASE ENTER THE FIRST TERM :98

PLEASE ENTER THE LAST TERM :100

THE FINAL SUM IS : 297

PRESS Y TO REPEAT ELSE EXIT PRESSING ANY KEY : y

b)

PLEASE ENTER THE FIRST TERM :12

PLEASE ENTER THE LAST TERM :1309

THE FINAL SUM IS : 857329

PRESS Y TO REPEAT ELSE EXIT PRESSING ANY KEY : n

PROGRAM EXCLUSIVELY CODED BY MUHAMMAD IRFAN ARSHADOF CLASS 11.

ANY MODIFICATION DONE HERBY INVITE LEGAL ACTION.

SUGGESTIONS AND COMMENTS WELCOME AT chand4202002@yahoo.com

/ SUM OF FRACTIONS FROM 1 ... 1/N

#include<iostream.h>

#include<conio.h>

void main()

{ char des;

clrscr();

do

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 174/400

{ long float num,temp, sum=0;

clrscr();

cout<<"ENTER THE VALUE FOR nth DENOMINATOR : " ;

cin>>num;

cout<<"\n";

for(temp=1;temp<=num;temp++)

{ sum=sum+(1/temp);

cout<<sum << " + ";

}

cout<<"\n\nTHE SUM IS : "<<sum;

cout<<"\n\nREPEAT? (y/n) : ";

cin>>des;

}

while(des=='y'||des=='Y');

getch();

}

*Output

a)

ENTER THE VALUE FOR nth DENOMINATOR : 7

1 + 1.5 + 1.833333 + 2.083333 + 2.283333 + 2.45 + 2.592857 +

THE SUM IS : 2.592857

REPEAT? (y/n) : y

b)

ENTER THE VALUE FOR nth DENOMINATOR : 18

1 + 1.5 + 1.833333 + 2.083333 + 2.283333 + 2.45 + 2.592857 + 2.717857 + 2.828968

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 175/400

+ 2.928968 + 3.019877 + 3.103211 + 3.180134 + 3.251562 + 3.318229 + 3.380729 +

3.439553 + 3.495108 +

THE SUM IS : 3.495108

REPEAT? (y/n) : n

/CALCULATE THE FACTORS OF A GIVEN NUMBER

#include<iostream.h>

#include<conio.h>

void main ()

{ int num, fact, gfact;

clrscr ();

cout<<"ENTER A NUMBER : ";

cin >> num;

gfact=num/2;

cout<<"THE FACTORS OF " << num << " ARE : " << endl;

for ( fact=1; fact<=gfact; fact=fact+1)

{

if (num%fact==0)

cout << fact << endl;

}

getch ();

}

*OUTPUT

ENTER A NUMBER : 90

THE FACTORS OF 90 ARE :

1

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 176/400

2

3

5

6

9

10

15

18

30

45

/ FACTORIAL OF A NUMBER

#include<iostream.h>

#include<conio.h>

void main()

{ char choice;

do

{ clrscr();

long double num, i, fact=1;

cout<<"\nENTER THE NUMBER : ";

cin>>num;

for(i=num;i>=1;i--)

fact=fact*i;

cout<<"\nTHE FACTORIAL OF " << num <<" IS " << fact;

cout<<"\n\nREPEAT THE PROGRAM (y/n) : ";

cin>>choice;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 177/400

}while(choice=='y'||choice=='Y');

getch();

}

*Output

a) 

ENTER THE NUMBER : 63

THE FACTORIAL OF 63 IS 1.982608e+87

REPEAT THE PROGRAM (y/n) : y

b)

ENTER THE NUMBER : 81

THE FACTORIAL OF 81 IS 5.797126e+120

REPEAT THE PROGRAM (y/n) : y

c)

ENTER THE NUMBER : 7

THE FACTORIAL OF 7 IS 5040

REPEAT THE PROGRAM (y/n) : y

d)

ENTER THE NUMBER : 9

THE FACTORIAL OF 9 IS 362880

REPEAT THE PROGRAM (y/n) : y

e)

ENTER THE NUMBER : 18

THE FACTORIAL OF 18 IS 6.402374e+15

REPEAT THE PROGRAM (y/n) : n

/ TO CALCULATE THE SUM OF DIGITS IN A NUMBER

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 178/400

#include<iostream.h>

#include<conio.h>

void main ()

{ long num, digit, sum;

clrscr();

cout << " ENTER A NUMBER : ";

cin >> num;

for (sum=0; num!=0; num=num/10)

{

digit=num%10;

sum=sum+digit;

}

cout << "\nTHE SUM OF THE DIGITS : "<<sum;

getch();

}

*OUTPUT

ENTER A NUMBER : 98250237

THE SUM OF THE DIGITS : 36

COMPOUND INTEREST BY SIMPLE INTEREST

#include<iostream.h>

#include<conio.h>

void main()

{

long float interest, prince, rate, amt;

int time, temp, r;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 179/400

char choice;

do

{

clrscr ();

cout<<"PLEASE ENTER THE PRINCIPAL AMOUNT : ";

cin>>prince;

cout<<"\nENTER THE RATE OF INTEREST : ";

cin>>rate;

cout<<"\nENTER THE TIME : ";

cin>>time;

amt=prince;

cout<<"\n\tTIME\tSIMPLE INTEREST\tAMOUNT";

for(r=8, temp=0,interest=0;temp<=time;temp++, r++)

{

cout<<"\n\t"<<temp<<"\t"<<interest;

gotoxy(33,r);

cout<<amt;

interest=(amt*rate)/100;

amt=amt+interest;

}

cout<<"\n\tClosing"<<"\t"<<interest;

cout<<amt;

cout<<"\n\nTHUS, THE FINAL AMOUNT IS : "<<amt;

cout<<"\n\nREPEAT? (y/n) : ";

cin>>choice;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 180/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 181/400

{ float num1,num2,den1,den2,result;

char sign, choice;

do

{ clrscr();

cout<<"FRACTION 1 : "<<endl;

cout<<"\nENTER THE NUMERATOR : ";

cin>>num1;

cout<<"\nENTER THE DENOMINATOR : ";

cin>>den1;

cout<<"\nENTER THE CALCULATION OPERATOR (+, -, *, /) : ";

cin>>sign;

cout<<"\nFRACTION 2 : "<<endl;

cout<<"\nENTER THE NUMERATOR : ";

cin>>num2;

cout<<"\nENTER THE DENOMINATOR : ";

cin>>den2;

if(num1==0 || num2==0 || den1==0 || den2==0)

{

cout<<"\nOOPS!!! INVALID ENTRY. BYE! ";

exit(0);

}

switch(sign)

{

case '+': result=((num1/den1)+(num2/den2)); break;

case '-': result=((num1/den1)-(num2/den2)); break;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 182/400

case '*': result=((num1/den1)*(num2/den2)); break;

case '/': result=((num1/den1)/(num2/den2)); break;

default :

cout<<"\nOOPS!!!INVALID CALCULATION OPERATOR. BYE!!";

exit(0);

}

cout<<"\nRESULT IS : "<<result;

cout<<"\n\nDO YOU WISH TO RE-EXECUTE THE PROGRAM? (Y/N) : ";

cin>>choice;

}

while(choice=='y'||choice=='Y');

getch();

}

*OUTPUT

FRACTION 1 :

ENTER THE NUMERATOR : 12

ENTER THE DENOMINATOR : 23

ENTER THE CALCULATION OPERATOR (+, -, *, /) : *

FRACTION 2 :

ENTER THE NUMERATOR : 12

ENTER THE DENOMINATOR : 23

RESULT IS : 0.272212

DO YOU WISH TO RE-EXECUTE THE PROGRAM? (Y/N) : n

/ SUM OF ALL TERMS OF AN ARRAY INPUT BY THE USER

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 183/400

#include<iostream.h>

#include<conio.h>

void main()

{ clrscr(); long float num[10], sum=0, y=1;

cout<<"\nEnter 10 elements for the array : "<<endl<<endl;

for(;y<=10;y++)

{

cout<<"\nEntry : "<<y<<endl<<endl; cout<<"Enter : ";

cin>>num[y]; sum+=num[y];

}

cout<<"\n\nThe sum all the elements entered for the array is : " << sum;

getch();

}

* Output

Enter 10 elements for the array :

Entry : 1

Enter : 1

Entry : 2

Enter : 22

Entry : 3

Enter : 345

Entry : 4

Enter : 454

Entry : 5

Enter : 67

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 184/400

Entry : 6

Enter : 234

Entry : 7

Enter : 564

Entry : 8

Enter : 234

Entry : 9

Enter : 563

Entry : 10

Enter : 673

The sum all the elements entered for the array is : 3157

* TO ACCEPT 10 NUMBERS IN AN ARRAY AND PRINT THE SUM OF:

ALL ODD ELEMENTS IN THE ARRAY ALL EVEN ELEMENTS IN THE ARRAY EVERY 3RD ELEMENT IN THE

ARRAY */

#include<iostream.h>

#include<conio.h>

void main()

{ int array[10], count=0, sum1=0, sum2=0, sum3=0;

clrscr();

//*********input**************

cout<<"\nENTER 10 NUMBERS FOR THE ARRAY : " <<endl<<endl;

for(count=0;count<10;count++)

{ cin >> array[count];

}

//************process***********

for(count=0 ; count<10 ; count++)

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 185/400

{

if(count%2!=0)

sum1=sum1+array[count];

else

sum2=sum2+array[count];

}

for(count=2 ; count<10 ; count=count+3)

{

sum3=sum3+array[count];

}

//**************output***********

cout<<"\nTHE RESULTS ARE : " << endl;

cout<<"\n1: "<<"SUM OF ALL ODD ELEMENTS : "<<sum1<<endl;

cout<<"\n2: "<<"SUM OF ALL EVEN ELEMENTS : "<<sum2<<endl;

cout<<"\n3: "<<"SUM OF EVERY 3rd ELEMENT IN THE ARRAY : "<< sum3 <<endl;

getch();

}

*OUTPUT

ENTER 10 NUMBERS FOR THE ARRAY :

12

23

34

45

56

67

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 186/400

78

89

90

99

THE RESULTS ARE :

1: SUM OF ALL ODD ELEMENTS : 323

2: SUM OF ALL EVEN ELEMENTS : 270

3: SUM OF EVERY 3rd ELEMENT IN THE ARRAY : 191

/ INPUT 3 DIGITS AND FORM A NEW NUMBER

#include<iostream.h>

#include<conio.h>

void main()

{ char choice, ch1,ch2, ch3, ch4, s[4];

int dig1, dig2, dig3, num2, num3, num4, num5, num6;

do

{

clrscr();

cout<<"\nENTER THREE DIGIT CHARACTER : \n";

cin>>s;

ch1=s[0];

ch2=s[1];

ch3=s[2];

dig1=(ch1-'0');

dig2=(ch2-'0');

dig3=(ch3-'0');

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 187/400

num2=dig1*100 + dig3*10 + dig2;

num3=dig2*100 + dig3*10 + dig1;

num4=dig2*100 + dig1*10 + dig3;

num5=dig3*100 + dig2*10 + dig1;

num6=dig3*100 + dig1*10 + dig2;

cout<<"\nTHE NUMBERS FORMED ARE : \n"<< num2;

cout<<"\n" <<num3<<"\n"<<num4<<"\n"<<num5<<"\n"<<num6;

cout<<"\n\nDO YOU WISH TO REPEAT THE PROGRAM? (Y/N) : ";

cin>>choice;

}

while(choice=='y'||choice=='Y');

getch();

}

OUTPUT

ENTER THREE DIGIT CHARACTER :

345

THE NUMBERS FORMED ARE :

354

453

435

543

534

DO YOU WISH TO REPEAT THE PROGRAM? (Y/N) : n

PRINT THE BILL INDEX OF ALL USERS ALONGWITH THEIR ELECTRICITY

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 188/400

CONSUMPTION UNITS AND THE BILL TO BE PAYED.

#include<iostream.h>

#include<conio.h>

void main()

{ long consumption[25], charges[25];

int count, y;

char name[5][25];

clrscr();

for(count=0; count<5; count++)

{

cout<<"ENTER THE NAME : ";

cin>>name[count];

cout<<"ENTER THE ELECTRICITY CONSUMPTION : ";

cin >> consumption[count];

if(consumption[count]<=400)

charges[count]=consumption[count]*60;

else if (consumption[count]>400 && consumption[count]<=900)

charges[count]=((consumption[count]-100)*80) + 6000;

else if(consumption[count]>900)

charges[count]=((consumption[count]-300)*90) + 22000;

}

clrscr();

gotoxy(1,1);

cout << "NAME";

gotoxy(7,1);

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 189/400

cout << "CONSUMPTION";

gotoxy(20,1);

cout << "CHARGES" <<endl;

for(count=0, y=3; count<5; count++, y++)

{

gotoxy(1,y);

cout<<name[count];

gotoxy(12,y);

cout<<consumption[count];

gotoxy(20,y);

cout<<charges[count];

}

getch();

}

*OUTPUT

ENTER THE NAME : VISHAL

ENTER THE ELECTRICITY CONSUMPTION : 950

ENTER THE NAME : RAVI

ENTER THE ELECTRICITY CONSUMPTION : 750

ENTER THE NAME : RAM

ENTER THE ELECTRICITY CONSUMPTION : 375

ENTER THE NAME : MOHAN

ENTER THE ELECTRICITY CONSUMPTION : 625

ENTER THE NAME : HARSH

ENTER THE ELECTRICITY CONSUMPTION : 1200

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 190/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 191/400

hra[count]=0.55*basic[count];

da[count]=0.20*basic[count];

it[count]=0.30*basic[count];

pf[count]=0.10*basic[count];

gross_sal[count]=basic[count]+hra[count]+da[count];

gross_ded[count]=it[count]+pf[count];

net[count]=gross_sal[count]-gross_ded[count];

}

clrscr();

cout<<"Employee Payslip\n\n";

cout<<"Number\t" <<"Name\t" << "Basic\t" << "Gr.Sal\t" << "Gr.Ded\t";

cout<<"Net Salary\n\n";

for(count=0;count<5;count++)

{

cout<<eno[count]<<"\t"<<name[count]<<"\t"<<basic[count]

<<"\t"<<gross_sal[count] <<"\t"<< gross_ded[count]<<"\t"

<<net[count]<<"\n\n";

}

cout<<"\n\nRepeat ?(y/n) : ";

cin>>choice;

}

while(choice=='y'||choice=='Y');

getch();

}

Output

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 192/400

Enter name : Vipul

Enter employee number : 1

Enter Basic Salary : 76937

Enter name : Rachit

Enter employee number : 2

Enter Basic Salary : 63636

Enter name : Kunchit

Enter employee number : 3

Enter Basic Salary : 89376

Enter name : Ganesh

Enter employee number : 4

Enter Basic Salary : 74893

Enter name : Kunj

Enter employee number : 5

Enter Basic Salary : 92834

Employee Payslip

Number Name Basic Gr.Sal Gr.Ded Net Salary

1 Vipul 76937 134639 30774 103865

2 Rachit 63636 111362 25453 85909

3 Kunchit 89376 156407 35749 120658

4 Ganesh 74893 131062 29956 101106

5 Kunj 92834 162458 37133 125325

Repeat ?(y/n) :n

PROGRAM TO REVERSE A VECTOR 

#include<iostream.h>

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 193/400

#include<conio.h>

void main()

{ char choice;

do

{

clrscr();

int vec[10], count1, count2;

cout<<"ENTER TEN ELEMENTS FOR VECTOR :\n";

for(count1=0;count1<10;count1++)

cin>>vec[count1];

cout<<"\n\n";

for(count1=0, count2=9;count1<5;count1++,count2--)

{

vec[count1]=vec[count1]+vec[count2];

vec[count2]=vec[count1]-vec[count2];

vec[count1]=vec[count1]-vec[count2];

}

cout<<"\n\nTHE ORIGINAL VECTOR IS AS FOLLOWS : \n\n";

for(count1=0;count1<10;count1++)

cout<<" " <<vec[count1];

cout<<"\n\nTHE REVERSED VECTOR IS AS FOLLOWS : \n\n";

for(count1=0; count1<10;count1++)

cout<<" "<<vec[count1];

cout<<"\n\nDO YOU WISH TO RE-EXECUTE THE PROGRAM?(Y/N) : ";

cin>>choice;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 194/400

}

while(choice=='y'||choice=='Y');

getch();

}

OUTPUT

ENTER TEN ELEMENTS FOR VECTOR :

12

23

34

45

56

67

78

89

90

98

THE ORIGINAL VECTOR IS AS FOLLOWS :

12 23 34 45 56 67 78 89 90 98

THE REVERSED VECTOR IS AS FOLLOWS :

98 90 89 78 67 56 45 34 23 12

DO YOU WISH TO RE-EXECUTE THE PROGRAM?(Y/N) : N

PROGRAM TO FIND THE LARGEST AND SMALLEST ELEMENTS IN A VECTOR

#include<iostream.h>

#include<conio.h>

void main()

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 195/400

{ char choice;

do

{

clrscr();

int count, num, vec[50], large, small;

cout<<"ENTER HOW MANY ELEMENTS ARE THERE IN THE VECTOR (MAX 50) : ";

cin>>num;

cout<<"\nENTER THE VALUES IN THE VECOR \n";

for(count=0; count<num; count++)

cin>>vec[count];

large=small=vec[1];

for(count=0; count<num;count++)

{

if(vec[count]>large)

large=vec[count];

else if(vec[count]<small)

small=vec[count];

else

continue;

}

cout<<"\nTHE LARGEST ELEMENT IS : "<<large<<endl;

cout<<"\nTHE SMALLEST ELEMENT IS : "<<small<<endl;

cout<<"\nDO YOU WISH TO RE-EXECUTE THE PROGRAM?(Y/N) : ";

cin>>choice;

}

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 196/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 197/400

#include<iostream.h>

#include<conio.h>

void main()

{

char choice;

int count1, count2, count3, num, ans=0;

float vec[20];

do

{

clrscr();

cout<<"\nENTER THE SIZE OF THE VECTOR(MAX. 20) : ";

cin>>num;

cout<<"\nENTER THE ELEMENTS FOR THE VECTOR: \n";

for(count1=0; count1<num; count1++)

cin>>vec[count1];

cout<<"\nTHE ORIGINAL VECTOR:\n";

for(count1=0; count1<num; count1++)

cout<<"\n"<<vec[count1];

for(count1=0; count1<num; count1++)

{

for(count2=count1+1; count2<num; count2++)

{

if(vec[count1]==vec[count2])

{

num=num-1;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 198/400

for(count3=count2; count3<num; count3++)

vec[count3] =vec [count3+1];

ans=1;

count2--;

}

}

}

if(ans==0)

cout<<"\nVECTOR IS WITHOUT DUPLICATES:\n";

else

{

cout<<"\n\nVECTOR AFTER DELETING THE DUPLICATES: \n";

for(count2=0; count2<num; count2++)

cout<<"\n"<<vec[count2];

}

cout<<"\n\nDO YOU WISH TO RE-EXECUTE THE PROGRAM? (Y/N) : ";

cin>>choice;

}

while(choice=='y'||choice=='Y');

getch();

}

OUTPUT

ENTER THE SIZE OF THE VECTOR(MAX. 20) : 9

ENTER THE ELEMENTS FOR THE VECTOR:

231

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 199/400

345

32

45

76

34

32

231

345

THE ORIGINAL VECTOR:

231

345

32

45

76

34

32

231

345

VECTOR AFTER DELETING THE DUPLICATES:

231

345

32

45

76

34

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 200/400

DO YOU WISH TO RE-EXECUTE THE PROGRAM? (Y/N) : n

PLAYER DETAILS USING ARRAYS 

#include<iostream.h>

#include<conio.h>

void main()

{ clrscr();

char name[30];

int count, matches;

float runs[10],balls[10];

long double sr[10], avgsr, temp=0;

cout <<"\nENTER PLAYER NAME : ";

cin.getline(name,30);

cout<<"\nENTER NUMBER OF MATCHES PLAYED : ";

cin>>matches;

for(count=1;count<=matches;count++)

{

cout<<"\nENTER RUNS SCORED IN MATCH "<<count<<" : ";

cin>>runs[count];

cout<<"\nENTER BALLS PLAYED IN MATCH "<<count<<" : ";

cin >> balls[count];

sr[count]=(runs[count]*100)/balls[count];

temp+=sr[count];

}

avgsr=temp/matches;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 201/400

clrscr();

cout<<"\nPLAYER NAME : "<< name <<endl;

for(count=1;count<=matches;count++)

{

cout<<"\nRUNS SCORED IN MATCH "<<count<<" : "<< runs[count] <<endl;

cout<<"\nBALLS PLAYED IN MATCH "<<count<<" : "<< balls[count]<<endl;

cout<<"\nSTRIKE RATE IN MATCH "<<count<< sr[count]<<endl<<endl;

}

cout<<"\nAVERAGE STRIKE RATE : " <<avgsr<<endl;

getch();

}

OUTPUT

ENTER PLAYER NAME : ROHAN GAVASKAR

ENTER NUMBER OF MATCHES PLAYED : 5

ENTER RUNS SCORED IN MATCH 1 : 79

ENTER BALLS PLAYED IN MATCH 1 : 76

ENTER RUNS SCORED IN MATCH 2 : 89

ENTER BALLS PLAYED IN MATCH 2 : 95

ENTER RUNS SCORED IN MATCH 3 : 84

ENTER BALLS PLAYED IN MATCH 3 : 97

ENTER RUNS SCORED IN MATCH 4 : 108

ENTER BALLS PLAYED IN MATCH 4 : 105

ENTER RUNS SCORED IN MATCH 5 : 120

ENTER BALLS PLAYED IN MATCH 5 : 150

PLAYER NAME : ROHAN GAVASKAR

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 202/400

RUNS SCORED IN MATCH 1 : 79

BALLS PLAYED IN MATCH 1 : 76

STRIKE RATE IN MATCH 1103.947368

RUNS SCORED IN MATCH 2 : 89

BALLS PLAYED IN MATCH 2 : 95

STRIKE RATE IN MATCH 293.684211

RUNS SCORED IN MATCH 3 : 84

BALLS PLAYED IN MATCH 3 : 97

STRIKE RATE IN MATCH 386.597938

RUNS SCORED IN MATCH 4 : 108

BALLS PLAYED IN MATCH 4 : 105

STRIKE RATE IN MATCH 4102.857143

RUNS SCORED IN MATCH 5 : 120

BALLS PLAYED IN MATCH 5 : 150

STRIKE RATE IN MATCH 580

AVERAGE STRIKE RATE : 93.417332

WHITE SPACE CONFIRMATION 

#include<iostream.h>

#include<conio.h>

void main()

{ char choice, ch;

do

{ clrscr();

cout<<"ENTER THE CHARACTER : ";

cin.get(ch);

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 203/400

if(ch=='\t')

cout<<"\n\nWHITE SPACE \'TAB\' CHARACTER \n";

else if (ch=='\n')

cout<<"\n\nWHITE SPACE \'NEW LINE \' CHARACTER \n";

else if (ch==' ')

cout<<"\n\nWHITE SPACE \'SPACE\' CHARACTER \n";

else

cout<<"\n\n IT IS A DIFFERENT CHARACTER AND NOT A WHITE SPACE.";

cout<<"\n\nDO YOU WISH TO REPEAT THE PROGRAM? (Y/N) : ";

cin>>choice;

}while(choice=='y'||choice=='Y');

}

OUTPUT

ENTER THE CHARACTER :

WHITE SPACE 'SPACE' CHARACTER

DO YOU WISH TO REPEAT THE PROGRAM? (Y/N) : Y

ENTER THE CHARACTER :

WHITE SPACE 'NEW LINE ' CHARACTER

DO YOU WISH TO REPEAT THE PROGRAM? (Y/N) : Y

ENTER THE CHARACTER :

WHITE SPACE 'TAB' CHARACTER

DO YOU WISH TO REPEAT THE PROGRAM? (Y/N) : N

CONFIRM PRESENCE OF A CHARACTER IN A STRING 

#include<iostream.h>

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 204/400

#include<conio.h>

#include<string.h>

void main()

{ char choice, ch, str[70], flag;

int len, count;

do

{

clrscr();

cout<<"\nENTER THE STRING:\n\n";

cin.getline(str, 70);

len=strlen(str);

cout<<"\nENTER A CHARACTER: ";

cin.get(ch);

flag='n';

for(count=0;str[count]!=len;count++)

{

if(ch==str[count])

{

flag='Y';

break;

}

}

if(flag=='Y')

{

cout<<"\n";

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 205/400

cout.put(ch);

cout<<" is contained in the string : \n\n";

cout.write(str,len);

}

else

{

cout<<"\n";

cout.put(ch);

cout<<" is not contained in the string : \n\n";

cout.write(str,len);

}

cout<<"\n\nDO YOU WISH TO REPEAT THE PROGRAM?

(Y/N) : ";

cin>>choice;

}

while(choice=='y'||choice=='Y');

getch();

}

OUTPUT 

ENTER THE STRING:

lion and tiger kileed the zebra

ENTER A CHARACTER: z

z is contained in the string :

lion and tiger kileed the zebra

DO YOU WISH TO REPEAT THE PROGRAM? (Y/N) : n

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 206/400

COUNT THE NUMBER OF VOWELS IN A STRING.

#include<iostream.h>

#include<conio.h>

void main()

{ char str[25];

int count, consonant=0, vowel=0, digit=0;

clrscr();

cout<<"ENTER A WORD : ";

cin.getline(str,25);

for(count=0;str[count]!='\0';count++)

{

if(str[count]=='A'||str[count]=='a'||str[count]=='E'

||str[count]=='e'||str[count]=='I'||str[count]=='i'||

str[count]=='O'||str[count]=='o'||str[count]=='U'||

str[count]=='u')

{ vowel++; }

else

{ consonant++; }

}

cout<<"consonant: "<<consonant;

cout<<"\nvowel: "<<vowel;

getch();

}

ENCRYPTION OF A STRING 

#include<iostream.h>

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 207/400

#include<conio.h>

#include<stdio.h>

void main()

{ char choice, str1[21], str2[21], ch;

int count=0;

do

{

clrscr();

cout<<"ENTER A STRING : ";

gets(str1);

for (count=0; str1[count]!='\0'; count++)

str2[count]=255-str1[count];

str2[count]='\0';

puts("\nTHE ENCRYPTED STRING IS : ");

cout<<str2;

cout<<"\n\nDO YOU WISH TO REPEAT THE PROGRAM? (Y/N) : ";

cin>>choice;

}while(choice=='y'||choice=='Y');

}

OUTPUT

ENTER A STRING : godfather

THE ENCRYPTED STRING IS :

 

DO YOU WISH TO REPEAT THE PROGRAM? (Y/N) : y

ENTER A STRING : rachit

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 208/400

THE ENCRYPTED STRING IS :

oe 

DO YOU WISH TO REPEAT THE PROGRAM? (Y/N) : n

ENTER A STRING : GOOD MORNING TEACHER

THE ENCRYPTED STRING IS :

¸°°»ß²°±¶±¸ß«º¾¼.º

DO YOU WISH TO REPEAT THE PROGRAM? (Y/N) : N

CONVERT A STRING INTO UPPERCASE

#include<iostream.h>

#include<conio.h>

#include<ctype.h>

#include<string.h>

void main()

{

clrscr();

char str[50];

int flag=1;

cout<<"\nENTER A STRING : \n\n";

cin.getline(str,50);

for(int i=0; str[i]!='\0';i++)

{

if(islower(str[i]))

{

flag=1;

str[i]=toupper(str[i]);

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 209/400

}

}

if((flag==1)||(str[i]=='\0'))

{

cout<<"\nUPPERCASE STRING IS :\n\n";

cout<<str;

}

getch();

}

/*OUTPUT

ENTER A STRING :

rachit is coding programs for his project

UPPERCASE STRING IS :

RACHIT IS CODING PROGRAMS FOR HIS PROJECT

PROGRAM TO FIND THE SUBSTRING OF A GIVEN STRING.

#include<iostream.h>

#include<conio.h>

#include<string.h>

#include<process.h>

void main()

{ clrscr();

char mainstr[50], substr[50];

int pos, count, count1, count2, len, num, temp;

cout<<"ENTER THE MAIN STRING ( MAX 49 CHARACTERS) : \n";

cin.getline(mainstr, 50);

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 210/400

len=strlen(mainstr);

cout<<"\nENTER THE STARTING POSITION OF SUBSTRING : ";

cin>>pos;

if(pos>len)

{

cout<<"\n\nSTARTING POSITION EXCEEDS THE TOTAL LENGTH OF STRING";

exit(0);

}

cout<<"\n\nENTER THE NUMBER OF CHARACTERS IN SUBSTRING : ";

cin>>count;

if(pos<=0)

{

cout<<"\n\nEXTRACTED STRING IS EMPTY.";

exit(0);

}

else if (((pos+count)-1)>len)

{

cout<<"\n\nSTRING TO BE EXTRACTED EXCEEDS LENGTH \n";

num=(len-pos);

}

else

num=count;

count2=0;

for(count1=--pos; count2<num;count2++, count1++)

substr[count2]=mainstr[count1];

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 211/400

cout<<"\n\nTHE SUBSTRING IS : ";

cout<<substr;

for(count=0;count<50;count++)

substr[count]='\0';

getch();

}

OUTPUT

ENTER THE MAIN STRING ( MAX 49 CHARACTERS) :

GOOD MORNING TEACHER

ENTER THE STARTING POSITION OF SUBSTRING : 3

ENTER THE NUMBER OF CHARACTERS IN SUBSTRING : 6

THE SUBSTRING IS : OD MOR

PROGRAM TO SEARCH FOR A PATTERN STRING IN THE THE MAIN STRING

#include<iostream.h>

#include<conio.h>

#include<string.h>

void main()

{ clrscr();

char mainstr[50], patstr[50];

int count1, count2, count3=0, len1, len2, flag, pos, found=0;

cout<<"ENTER THE MAIN STRING : ";

cin.getline(mainstr, 50);

cout<<"ENTER THE PATTERN STRING : ";

cin.getline(patstr, 50);

len1= strlen(mainstr);

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 212/400

len2= strlen(patstr);

flag=0;

for(count1=0; count1<len1; count1++)

{

for(count2=count1; count2<len1; )

{

if(mainstr[count2]!=patstr[0])

{

flag=1;

count2++;

}

else if(mainstr[count2]==patstr[0])

{

pos=count2;

count3=0;

while(mainstr[count2]==patstr[count3])

{

flag=0;

count2++;

count3++;

}

if(count3>=len2)

{

cout<<"\nPATTERN FOUND AT POSITION " << pos+1 << endl;

found=1;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 213/400

break;

}

else

count3=0;

}

}

if ( found)

break;

}

if((flag!=0)||((flag==0)&&(count3<len2)))

cout<<"\nPATTERN NOT FOUND."<<endl;

getch();

}

OUTPUT

ENTER THE MAIN STRING : Rachit

ENTER THE PATTERN STRING : ach

PATTERN FOUND AT POSITION 2

PROGRAM TO CONCATENATE TWO STRINGS

#include<iostream.h>

#include<conio.h>

#include<string.h>

void main()

{ char choice;

do

{

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 214/400

clrscr();

char str1[25], str2[25], str3[25];

int count1, count2;

cout<<"ENTER THE FIRST STRING : ";

cin.getline(str1, 25);

cout<<"ENTER THE SECOND STRING : ";

cin.getline(str2, 25);

for(count1=0; str1[count1]!='\0'; count1++)

{

str3[count1]=str1[count1];

}

str3[count1]=' ';

count1++;

for(count2=0; str2[count2]!='\0'; count2++)

{

str3[count1+count2]=str2[count2];

}

str3[count1+count2]='\0';

cout<<"\nTHE NEW CONCATENATED STRING IS : \n\n";

cout<<str3;

cout<<"\n\nDO YOU WISH TO RE-EXECUTE THE PROGRAM?(Y/N): ";

cin>>choice;

}

while(choice=='Y'||choice=='y');

getch();

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 215/400

}

OUTPUT

ENTER THE FIRST STRING : GOOD EVENING

ENTER THE SECOND STRING : MR. SATYANARAYAN

THE NEW CONCATENATED STRING IS :

GOOD EVENING MR. SATYANARAYAN

DO YOU WISH TO RE-EXECUTE THE PROGRAM?(Y/N): N

ADDITION OF TWO MATRICES 

#include<iostream.h>

#include<conio.h>

#include<process.h>

void main()

{ int a[10][10],b[10][10],c[10][10],count1, count2,ra,ca,rb,cb;

char choice;

do

{ clrscr();

cout<<"\nINPUT ROW FOR MATRIX A: ";

cin>>ra;

cout<<"\nINPUT COLUMN FOR MATRIX A: ";

cin>>ca;

cout<<"\nINPUT ROW FOR MATRIX B: ";

cin>>rb;

cout<<"\nINPUT COLUMN FOR MATRIX B: ";

cin>>cb;

if((ra==rb)&&(ca==cb))

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 216/400

cout<<"\nTHE TWO MATRICES CAN BE ADDED AS THEY ARE IDENTICAL.";

else

{

cout<<"\nTHE TWO MATRICES CANNOT BE ADDED SINCE THEY ARE INIDENTICAL.";

cout<<"\nTHANK YOU.";

exit(0);

}

cout<<"\n\nINPUT ELEMENTS FOR MATRIX A :\n";

for(count1=0;count1<ra;count1++)

{

cout<<"\n";

for(count2=0;count2<ca;count2++)

cin>>a[count1][count2];

}

cout<<"\n\nINPUT ELEMENTS FOR MATRIX B :\n";

for(count1=0;count1<rb;count1++)

{

cout<<"\n";

for(count2=0;count2<cb;count2++)

cin>>b[count1][count2];

}

for(count1=0;count1<ra;count1++)

{

for(count2=0;count2<ca;count2++)

c[count1][count2]=a[count1][count2]+b[count1][count2];

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 217/400

}

clrscr();

cout<<"MATRIX A: ";

for(count1=0;count1<ra;count1++)

{

cout<<"\n\n";

for(count2=0;count2<ca;count2++)

cout<<"\t"<<a[count1][count2];

}

cout<<"\n\nMATRIX B: ";

for(count1=0;count1<rb;count1++)

{

cout<<"\n\n";

for(count2=0;count2<cb;count2++)

cout<<"\t"<<b[count1][count2];

}

cout<<"\n\nMATRIX C (NEW TO REPRESENT THE SUM OF MATRICES A & B): ";

for(count1=0;count1<ra;count1++)

{

cout<<"\n\n";

for(count2=0;count2<ca;count2++)

cout<<"\t"<<c[count1][count2];

}

cout<<"\n\nDO YOU WISH TO RE-EXECUTE THE PROGRAM?(Y/N) : ";

cin>>choice;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 218/400

}

while(choice=='y'||choice=='Y');

getch();

}

OUTPUT

INPUT ROW FOR MATRIX A: 3

INPUT COLUMN FOR MATRIX A: 3

INPUT ROW FOR MATRIX B: 3

INPUT COLUMN FOR MATRIX B: 3

THE TWO MATRICES CAN BE ADDED AS THEY ARE IDENTICAL.

INPUT ELEMENTS FOR MATRIX A :

1

2

3

12

23

34

45

56

67

INPUT ELEMENTS FOR MATRIX B :

98

76

65

45

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 219/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 220/400

{ clrscr();

int a[10][10],b[10][10],c[10][10],count1, count2,ra,ca,rb,cb;

cout<<"\nINPUT ROW FOR MATRIX A: ";

cin>>ra;

cout<<"\nINPUT COLUMN FOR MATRIX A: ";

cin>>ca;

cout<<"\nINPUT ROW FOR MATRIX B: ";

cin>>rb;

cout<<"\nINPUT COLUMN FOR MATRIX B: ";

cin>>cb;

if((ra==rb)&&(ca==cb))

cout<<"\nSUBTRACTION BETWEEN THE TWO MATRICES IS POSSIBLE.";

else

{

cout<<"\nSUBTRACTION BETWEEN THE TWO MATRICES IS NOT POSSIBLE.";

cout<<"\nTHANK YOU.";

exit(0);

}

cout<<"\n\nINPUT ELEMENTS FOR MATRIX A :";

for(count1=0;count1<ra;count1++)

{

cout<<"\n";

for(count2=0;count2<ca;count2++)

cin>>a[count1][count2];

}

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 221/400

cout<<"\n\nINPUT ELEMENTS FOR MATRIX B :";

for(count1=0;count1<rb;count1++)

{

cout<<"\n";

for(count2=0;count2<cb;count2++)

cin>>b[count1][count2];

}

for(count1=0;count1<ra;count1++)

{

for(count2=0;count2<ca;count2++)

c[count1][count2]=a[count1][count2]-b[count1][count2];

}

clrscr();

cout<<"MATRIX A: ";

for(count1=0;count1<ra;count1++)

{

cout<<"\n\n";

for(count2=0;count2<ca;count2++)

cout<<"\t"<<a[count1][count2];

}

cout<<"\n\nMATRIX B: ";

for(count1=0;count1<rb;count1++)

{

cout<<"\n\n";

for(count2=0;count2<cb;count2++)

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 222/400

cout<<"\t"<<b[count1][count2];

}

cout<<"\n\nMATRIX C (NEW TO REPRESENT THE DIFFERENCE BETWEEN MATRICES A & B):

";

for(count1=0;count1<ra;count1++)

{

cout<<"\n\n";

for(count2=0;count2<ca;count2++)

cout<<"\t"<<c[count1][count2];

}

cout<<"\n\nDO YOU WISH TO RE-EXECUTE THE PROGRAM?(Y/N): ";

cin>>choice;

}while(choice=='Y'||choice=='y');

}

OUTPUT

INPUT ROW FOR MATRIX A: 3

INPUT COLUMN FOR MATRIX A: 3

INPUT ROW FOR MATRIX B: 3

INPUT COLUMN FOR MATRIX B: 3

SUBTRACTION BETWEEN THE TWO MATRICES IS POSSIBLE.

INPUT ELEMENTS FOR MATRIX A :

12

23

34

45

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 223/400

56

67

78

89

90

INPUT ELEMENTS FOR MATRIX B :

98

87

76

65

54

43

32

21

10

MATRIX A:

12 23 34

45 56 67

78 89 90

MATRIX B:

98 87 76

65 54 43

32 21 10

MATRIX C (NEW TO REPRESENT THE DIFFERENCE BETWEEN MATRICES A & B):

-86 -64 -42

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 224/400

-20 2 24

46 68 80

DO YOU WISH TO RE-EXECUTE THE PROGRAM?(Y/N): n */

MULTIPLICATION OF TWO MATRICES 

#include<iostream.h>

#include<conio.h>

#include<process.h>

void main()

{ long a[10][10],b[10][10],c[10][10];

int count1, count2,count3,ra,ca,rb,cb;

char choice;

do

{ clrscr();

cout<<"INPUT ROW FOR MATRIX A: ";

cin>>ra;

cout<<"\nINPUT COLUMN FOR MATRIX A: ";

cin>>ca;

cout<<"\nINPUT ROW FOR MATRIX B: ";

cin>>rb;

cout<<"\nINPUT COLUMN FOR MATRIX B: ";

cin>>cb;

if((ra==rb)&&(ca==cb))

cout<<"\nMULTIPLICATION OF THE TWO MATRICES IS POSSIBLE.";

else

{

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 225/400

cout<<"\nMULTIPLICATION OF THE TWO MATRICES IS NOT POSSIBLE.";

cout<<"\nTHANK YOU.";

exit(0);

}

cout<<"\n\nINPUT ELEMENTS FOR MATRIX A :";

for(count1=0;count1<ra;count1++)

{

cout<<"\n";

for(count2=0;count2<ca;count2++)

cin>>a[count1][count2];

}

cout<<"\n\nINPUT ELEMENTS FOR MATRIX B :";

for(count1=0;count1<rb;count1++)

{

cout<<"\n";

for(count2=0;count2<cb;count2++)

cin>>b[count1][count2];

}

for(count1=0;count1<ra;count1++)

{

for(count2=0;count2<cb;count2++)

{

c[count1][count2]=0;

for(count3=0;count3<ca;count3++)

{

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 226/400

c[count1][count2]+=a[count1][count3]*b[count3][count2];

}

}

}

clrscr();

cout<<"MATRIX A: ";

for(count1=0;count1<ra;count1++)

{

cout<<"\n\n";

for(count2=0;count2<ca;count2++)

cout<<" "<<a[count1][count2];

}

cout<<"\n\nMATRIX B: ";

for(count1=0;count1<rb;count1++)

{

cout<<"\n\n";

for(count2=0;count2<cb;count2++)

cout<<" "<<b[count1][count2];

}

cout<<"\n\nMATRIX C (NEW TO REPRESENT THE MULTIPLICATION OF MATRICES A & B):\n ";

for(count1=0;count1<ra;count1++)

{

cout<<"\n";

for(count2=0;count2<cb;count2++)

cout<<" "<<c[count1][count2];

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 227/400

cout<<"\n";

}

cout<<"\n\nDO YOU WISH TO RE-EXECUTE THE PROGRAM?(Y/N) : ";

cin>>choice;

}

while(choice=='Y'||choice=='y');

getch();

}

OUTPUT

INPUT ROW FOR MATRIX A: 3

INPUT COLUMN FOR MATRIX A: 3

INPUT ROW FOR MATRIX B: 3

INPUT COLUMN FOR MATRIX B: 3

MULTIPLICATION OF THE TWO MATRICES IS POSSIBLE.

INPUT ELEMENTS FOR MATRIX A :

12

23

34

45

56

67

78

89

90

INPUT ELEMENTS FOR MATRIX B :

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 228/400

0

98

87

76

65

54

43

32

21

MATRIX A:

12 23 34

45 56 67

78 89 90

MATRIX B:

0 98 87

76 65 54

43 32 21

MATRIX C (NEW TO REPRESENT THE MULTIPLICATION OF MATRICES A & B):

3210 3759 3000

7137 10194 8346

10634 16309 13482

DO YOU WISH TO RE-EXECUTE THE PROGRAM?(Y/N) : N */

PROGRAM TO FIND ROW SUM AND COLUMN SUM OF A MATRIX #include<iostream.h>

#include<conio.h>

void main()

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 229/400

{ char choice;

do

{ clrscr();

int a[10][10], rosm[10], colsm[10], row, col, count1, count2;

cout<<"ENTER THE NUMBER OF ROWS FOR MATRIX : ";

cin>>row;

cout<<"ENTER THE NUMBER OF COLUMN FOR MATRIX : ";

cin>>col;

cout<<"ENTER THE ELEMENTS FOR MATRIX :\n ";

for(count1=0;count1<row;count1++)

{ cout<<"\n";

for(count2=0; count2<col; count2++)

cin>>a[count1][count2];

}

for(count1=0; count1<row;count1++)

{

rosm[count1]=0;

for(count2=0;count2<col; count2++)

rosm[count1] += a[count1][count2];

}

for(count2=0; count2<col; count2++)

{

colsm[count2]=0;

for(count1=0;count1<row; count1++)

colsm[count2] += a[count1][count2];

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 230/400

}

cout<<"\n\nTHE MATRIX ALONGWITH ROWSUM AND COLUMNSUM IS :\n\n";

for(count1=0; count1<row;count1++)

{

for(count2=0; count2<col; count2++)

cout<<a[count1][count2]<<"\t";

cout<<"\t"<<rosm[count1]<< endl;

}

cout<<"\n";

for(count2=0; count2<col; count2++)

cout<<colsm[count2]<< "\t";

cout<<endl;

cout<<"\n\nDO YOU WISH TO RE-EXECUTE THE PROGRAM? (Y/N): ";

cin>>choice;

}while(choice=='Y'||choice=='y');

}

OUTPUT

ENTER THE NUMBER OF ROWS FOR MATRIX : 3

ENTER THE NUMBER OF COLUMN FOR MATRIX : 3

ENTER THE ELEMENTS FOR MATRIX :

25

36

45

49

63

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 231/400

72

70

81

90

THE MATRIX ALONGWITH ROWSUM AND COLUMNSUM IS :

25 36 45 106

49 63 72 184

70 81 90 241

144 180 207

DO YOU WISH TO RE-EXECUTE THE PROGRAM? (Y/N): n

PROGRAM TO FIND SUM OF ELEMENTS ABOVE AND BELOW THE

MAIN DIAGONAL OF MATRIX:

#include<iostream.h>

#include<conio.h>

void main()

{ int a[20][20], asum, bsum, row, col, count1, count2; char choice;

do

{

clrscr();

cout<<"ENTER THE NUMBER OF ROWS FOR MATRIX : ";

cin>>row;

cout<<"\nENTER THE NUMBER OF COLUMNS FOR MATRIX : ";

cin>>col;

cout<<"\nENTER THE ELEMENTS FOR THE MATRIX :\n\n";

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 232/400

for(count1=0;count1<row;count1++)

{

for(count2=0; count2<col; count2++)

cin>>a[count1][count2];

}

asum=0;

for(count1=0; count1<row;count1++)

{

for(count2=0;count2<col; count2++)

{

if(count1<count2)

asum+=a[count1][count2];

}

}

bsum=0;

for(count1=0; count1<row;count1++)

{

for(count2=0;count2<col; count2++)

{

if(count1>count2)

bsum+=a[count1][count2];

}

}

for(count1=0;count1<row;count1++)

{

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 233/400

cout<<"\n\n";

for(count2=0; count2<col; count2++)

cout<<"\t"<< a[count1][count2];

}

cout<<"\n\nTHE ELEMENTS OF THE MAIN DIAGONAL ARE : ";

for(count1=0; count1<row;count1++)

{

for(count2=0;count2<col; count2++)

{

if(count1==count2)

cout<< a[count1][count2] << " ";

}

}

cout<<"\n\nTHE SUM OF THE ELEMENTS ABOVE THE MAIN DIAGONAL : ";

cout<<asum;

cout<<"\n\nTHE SUM OF THE ELEMENTS BELOW THE MAIN DIAGONAL : ";

cout<<bsum;

cout<<"\n\nDO YOU WISH TO RE-EXECUTE THE PROGRAM? (Y/N) : ";

cin>>choice;

}

while(choice=='y'||choice=='Y');

getch();

}

Output

ENTER THE NUMBER OF ROWS FOR MATRIX : 4

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 234/400

ENTER THE NUMBER OF COLUMNS FOR MATRIX : 4

ENTER THE ELEMENTS FOR THE MATRIX :

1

2

3

4

5

6

7

8

9

18

27

45

63

72

49

35

1 2 3 4

5 6 7 8

9 18 27 45

63 72 49 35

THE ELEMENTS OF THE MAIN DIAGONAL ARE : 1 6 27 35

THE SUM OF THE ELEMENTS ABOVE THE MAIN DIAGONAL : 69

THE SUM OF THE ELEMENTS BELOW THE MAIN DIAGONAL : 216

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 235/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 236/400

}

clrscr();

cout<<"MATRIX A: ";

for(count1=0;count1<ra;count1++)

{

cout<<"\n\n";

for(count2=0;count2<ca;count2++)

cout<<"\t"<<a[count1][count2];

}

cout<<"\n\nMATRIX B (TRANSPOSED FORM OF MATRIX A): ";

for(count1=0;count1<ca;count1++)

{

cout<<"\n\n";

for(count2=0;count2<ra;count2++)

cout<<"\t"<<b[count1][count2];

}

cout<<"\n\nDO YOU WISH TO RE-EXECUTE THE PROGRAM?(Y/N) : ";

cin>>choice;

}

while(choice=='y'||choice=='Y');

getch();

}

OUTPUT

INPUT ROW FOR MATRIX A: 3

INPUT COLUMN FOR MATRIX A: 3

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 237/400

INPUT ELEMENTS FOR MATRIX A :

12

23

34

45

56

67

78

89

90

MATRIX A:

12 23 34

45 56 67

78 89 90

MATRIX B (TRANSPOSED FORM OF MATRIX A):

12 45 78

23 56 89

34 67 90

DO YOU WISH TO RE-EXECUTE THE PROGRAM?(Y/N) : n

TO SEARCH FOR POSITION OF A SEARCH NUMBER FROM THOSE INPUT:

#include<iostream.h>

#include<conio.h>

void main()

{ int num[15], search, count, flag=0;

clrscr();

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 238/400

cout<<"ENTER 15 INTEGERS FOR AN ARRAY : "<<endl<<endl;

for(count=1;count<=15;count++)

cin>>num[count];

cout<<"\nENTER THE SEARCH NUMBER FROM THE ABOVE ARRAY : ";

cin >> search;

count=1;

do

{

if(num[count]==search)

{

cout<<"\n\nTHE POSITION IS " << count;

flag=1;

}

count++;

}while(count<15);

if(num[count]==search)

{

cout<<"\n\nTHE POSITION IS " << count;

flag=1;

}

if(flag==0)

cout<<"SORRY!! SEARCH NUMBER NOT FOUND IN THE ARRAY.";

getch();

}

OUTPUT

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 239/400

ENTER 15 INTEGERS FOR AN ARRAY :

12

23

34

45

56

67

78

89

90

90

89

78

76

65

45

ENTER THE SEARCH NUMBER FROM THE ABOVE ARRAY : 45

THE POSITION IS 4

THE POSITION IS 15

BUBBLESORT : to arrange the elements of an array in the ascending order

#include<iostream.h>

#include<conio.h>

void main()

{

int num[7], swap=1, temp, i;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 240/400

clrscr();

//**********user input*************

cout<<"\nENTER 7 ELEMENTS FOR THE ARRAY:\n";

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

{

cout <<"\nENTRY "<<i+1<< " : ";

cin >> num[i];

}

//****************process**************

do

{

swap=0;

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

{

if(num[i]>num[i+1])

{

temp=num[i];

num[i]=num[i+1];

num[i+1]=temp;

swap=1;

}

}

}while(swap==1);

//***************output****************

clrscr();

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 241/400

cout<<"\nThe sorted array is as follows: " << endl;

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

cout<<"\n"<< num[i]<<endl;

cout<<"\nThe conversely sorted array is as follows : " <<endl;

for(i=6; i>=0; i--)

cout<<"\n" << num[i] <<endl;

cout << "\nThis program has been created by MUHAMMAD IRFAN ARSHAD" <<endl;

getch();

}

OUTPUT

ENTER 7 ELEMENTS FOR THE ARRAY:

ENTRY 1 : 56

ENTRY 2 : 87

ENTRY 3 : 34

ENTRY 4 : 97

ENTRY 5 : 23

ENTRY 6 : 83

ENTRY 7 : 49

The sorted array is as follows:

23

34

49

56

83

87

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 242/400

97

The conversely sorted array is as follows :

97

87

83

56

49

34

23

This program has been created by Rachit Agrawal

Suggestions and Comments welcome via email at : rachit_agrawal9@gmail.com

MERGE TWO GIVEN ARRAYS. 

#include<iostream.h>

#include<conio.h>

void main()

{ int array1[10]={2,4,6,9,12,19,17,19,21,22};

int array2[15]={0,1,3,5,7,8,10,11,13,14,16,18,20,23,24};

int array3[25], count1=0, count2=0, count3=0, count4;

clrscr();

do

{

if(array1[count1]<array2[count2])

{

array3[count3]=array1[count1];

cout<< array3[count3]<<"\t";

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 243/400

count1=count1+1;

}

else

{

array3[count3]=array2[count2];

cout<< array3[count3]<<"\t";

count2=count2+1;

}

}while(count1<9 && count2<15);

if(count1==9)

{

for(count4=count2;count4<15;count3++,count4++)

{

array3[count3]=array2[count4];

cout<<array3[count3]<<"\t";

}

}

getch();

}

OUTPUT

0 1 2 3 4 5 6 7 8 9

10 11 12 13 14 16 18 19 17 19

20 21 23 24

TO SORT GIVEN TWO INTEGER ARRAYS SEPARATELY AND THEN MERGE THEM

#include<iostream.h>

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 244/400

#include<conio.h>

void main()

{

//****************variable declaration**********************

int array1[10]={15,21,6,19,25,12,17,9,4,2};

int array2[15]={23,22,16,10,7,18,13,11,5,14,1,8,20,3,24}, array3[25];

int count=0, count1=0, count2=0, count3=0, swap=1, temp=0, count4;

clrscr();

cout<<"THE ORIGINAL ARRAYS ARE :\n\n";

for(count=0;count<10;count++)

cout<<array1[count]<<"\t";

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

for(count=0;count<15;count++)

cout<<array2[count]<<"\t";

//****************sorting**************

do

{

swap=0;

for(count=0; count<9; count++)

{

if(array1[count]>array1[count+1])

{

temp=array1[count];

array1[count]=array1[count+1];

array1[count+1]=temp;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 245/400

swap=1;

}

}

}while(swap==1);

do

{

swap=0;

for(count=0; count<14; count++)

{

if(array2[count]>array2[count+1])

{

temp=array2[count];

array2[count]=array2[count+1];

array2[count+1]=temp;

swap=1;

}

}

}while(swap==1);

//***************************merging******************************

do

{

if(array1[count1]<array2[count2])

{

array3[count3]=array1[count1];

count1++;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 246/400

}

else if (array1[count1]>array2[count2])

{

array3[count3]=array2[count2];

count2++;

}

else if(array1[count1]==array2[count2])

{

array3[count3]=array1[count1];

count1++;

count3++;

array3[count3]=array2[count2];

count2++;

}

count3++;

}while(count2<15);

if(count2==15)

{

for(count4=count1;count1<10;count1++, count3++)

array3[count3]=array1[count4];

}

//**************output****************

cout<<"\n\nTHE SORTED ARRAYS ARE :\n\n";

for(count=0;count<10;count++)

cout<<array1[count]<<"\t";

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 247/400

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

for(count=0;count<15;count++)

cout<<array2[count]<<"\t";

cout<<"\n\n\n\nTHE NEW ARRAY REQUIRED IS :\n" << endl;

for(count=0; count<25;count++)

cout<<array3[count]<<"\t";

getch();

}

OUTPUT

THE ORIGINAL ARRAYS ARE :

15 21 6 19 25 12 17 9 4 2

23 22 16 10 7 18 13 11 5 14

1 8 20 3 24

THE SORTED ARRAYS ARE :

2 4 6 9 12 15 17 19 21 25

1 3 5 7 8 10 11 13 14 16

18 20 22 23 24

THE NEW ARRAY REQUIRED IS :

1 2 3 4 5 6 7 8 9 10

11 12 13 14 15 16 17 18 19 20

21 22 23 24 25

GIVEN INTEGER ARRAY : 5 8 7 1 2 4 9 6 0 10 

NEW ARRAY TO BE FORMED : 9 7 5 2 0 1 4 6 8 10 

#include<iostream.h>

#include<conio.h>

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 248/400

void main()

{ int array[10]={5,8,7,1,2,4,9,6,0,10}, newarray[10];

int count1, count2, count3, count4, temp, swap;

clrscr();

cout<<"ORGINAL ARRAY :\n\n";

for(count1=0;count1<10;count1++)

cout<<array[count1]<<"\t";

do

{

swap=0;

for(count1=0;count1<9;count1++)

{

if(array[count1]>array[count1+1])

{

temp=array[count1];

array[count1]=array[count1+1];

array[count1+1]=temp;

swap=1;

}

}

}while(swap==1);

for(count1=0, count2=8,count3=9, count4=9;count1<5;count1++,count2-=2,count3--

,count4-=2)

{

newarray[count1]=array[count2];

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 249/400

newarray[count3]=array[count4];

}

cout<<"\n\nNEW ARRAY :\n\n";

for(count1=0;count1<10;count1++)

cout<<newarray[count1]<<"\t";

getch();

}

OUTPUT

ORGINAL ARRAY :

5 8 7 1 2 4 9 6 0 10

NEW ARRAY :

9 7 5 2 0 1 4 6 8 10

ARRAY MANIPULATION MENU 

#include<iostream.h>

#include<conio.h>

void main()

{ int array[5], newarray[6], count,num, pos,choice;

clrscr();

cout<<"ENTER 5 ELEMENTS FOR THE ARRAY :\n\n";

for(int i=1;i<=5;i++)

cin>>array[i];

do

{

clrscr();

cout<<"ARRAY MANIPULATION\n1 ADD ELEMENT\n2 DELETE ELEMENT\n";

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 250/400

cout<<"3 MODIFY ELEMENT\n4 SHOW ELEMENTS\n5 EXIT\n\n";

cout<<"ENTER YOUR CHOICE : "; cin>>choice;

clrscr();

cout<<"YOUR CHOICE : "<<choice<<endl<<endl;

switch(choice)

{

case 1: do

{

cout<<"ENTER THE POSITION FOR THE NEW ELEMENT : ";

cin>>pos;

}while(pos>6);

cout<<"\nENTER THE ELEMENT : ";

cin>>num;

for(i=1;i<pos;i++)

newarray[i]=array[i];

newarray[i]=num;

for(i=pos+1;i<=6;i++)

newarray[i]=array[i-1];

cout<<"\nTHE NEW ARRAY IS : \n\n";

for(i=1;i<=6;i++)

cout<<newarray[i]<<"\t";

getch();

break;

case 2:

do

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 251/400

{

cout<<"ENTER THE POSITION FOR THE ELEMENT TO BE DELETED: ";

cin>>pos;

}while(pos>5);

for(i=1;i<pos;i++)

newarray[i]=array[i];

for(i=pos;i<5;i++)

newarray[i]=array[i+1];

cout<<"\nTHE NEW ARRAY IS : \n\n";

for(i=1;i<5;i++)

cout<<newarray[i]<<"\t";

getch();

break;

case 3: do

{

cout<<"ENTER THE POSITION FOR THE ELEMENT TO BE MODIFIED: ";

cin>>pos;

}while(pos>5);

cout<<"\nENTER THE NEW ELEMENT : ";

cin>>num;

for(i=1;i<pos;i++)

newarray[i]=array[i];

newarray[i]=num;

for(i=pos+1;i<=5;i++)

newarray[i]=array[i];

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 252/400

cout<<"\nTHE NEW ARRAY IS : \n\n";

for(i=1;i<=5;i++)

cout<<newarray[i]<<"\t";

getch();

break;

case 4:

cout<<"\nTHE ELEMENTS ENTERED BY YOU ARE :\n\n";

for(i=1;i<=5;i++)

cout<<array[i]<<"\t";

getch();

break;

default: break;

}

}while(choice!=5);

if(choice==5)

cout<<"EXITING...!!!\n\nTHANK YOU FOR USING PROGRAM\n\nCODED BY RACHIT AGRAWAL.";

cout<<\nSUGGESSTIONS AND COMMENTS WELCOME AT chand4202002@yahoo.com.;

getch();

}

OUTPUT

ENTER 5 ELEMENTS FOR THE ARRAY :

7

16

25

34

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 253/400

43

ARRAY MANIPULATION

1 ADD ELEMENT

2 DELETE ELEMENT

3 MODIFY ELEMENT

4 SHOW ELEMENTS

5 EXIT

ENTER YOUR CHOICE : 1

YOUR CHOICE : 1

ENTER THE POSITION FOR THE NEW ELEMENT : 3

ENTER THE ELEMENT : 45

THE NEW ARRAY IS :

7 16 45 25 34 43

YOUR CHOICE : 2

ENTER THE POSITION FOR THE ELEMENT TO BE DELETED: 3

THE NEW ARRAY IS :

7 16 34 43

YOUR CHOICE : 3

ENTER THE POSITION FOR THE ELEMENT TO BE MODIFIED: 2

ENTER THE NEW ELEMENT : 54

THE NEW ARRAY IS :

7 54 25 34 43

YOUR CHOICE : 4

THE ELEMENTS ENTERED BY YOU ARE :

7 16 25 34 43

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 254/400

YOUR CHOICE : 5

EXITING...!!!

THANK YOU FOR USING PROGRAM

CODED BY RACHIT AGRAWAL.

SUGGESSTIONS AND COMMENTS WELCOME AT chand4202002@yahoo.com.

TO PRINT THE CUBE OF A NUMBER USING A FUNCTION 

#include<iostream.h>

#include<conio.h>

void main()

{ float cube(float);

float x,y;

clrscr();

cout<<"\nENTER A NUMBER : ";

cin>>x;

y=cube(x);

cout<<"\nTHE CUBE OF "<<x<<" is " << y;

getch();

}

float cube(float s)

{

float n;

n=s*s*s;

return n;

}

OUTPUT

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 255/400

ENTER A NUMBER : 15

THE CUBE OF 15 is 3375

TO PRINT THE LARGEST ELEMENT OF AN ARRAY USING FUNCTION

#include<iostream.h>

#include<conio.h>

void main()

{ char ch;

int i;

float amt[50], big;

float large(float array[],int n);

clrscr();

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

{

cout<<"ENTER ELEMENT NUMBER : "<<i+1<<" : ";

cin>>amt[i];

cout<<"WANT TO ENTER MORE? (Y/N) : ";

cin>>ch;

if(ch!='y'&& ch!='Y')

break;

}

if(i<50)

i++;

big=large(amt, i);

cout<<"\nTHE LARGEST ELEMENT OF THE ARRAY IS : "<<big<<endl;

getch();

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 256/400

}

float large(float array[], int n)

{

float max=array[0];

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

{

if(array[j]>max)

max=array[j];

}

return (max);

}

OUTPUT

ENTER ELEMENT NUMBER : 1 : 18

WANT TO ENTER MORE? (Y/N) : y

ENTER ELEMENT NUMBER : 2 : 25

WANT TO ENTER MORE? (Y/N) : y

ENTER ELEMENT NUMBER : 3 : 3

WANT TO ENTER MORE? (Y/N) : y

ENTER ELEMENT NUMBER : 4 : 24

WANT TO ENTER MORE? (Y/N) : y

ENTER ELEMENT NUMBER : 5 : 6

WANT TO ENTER MORE? (Y/N) : y

ENTER ELEMENT NUMBER : 6 : 23

WANT TO ENTER MORE? (Y/N) : y

ENTER ELEMENT NUMBER : 7 : 19

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 257/400

WANT TO ENTER MORE? (Y/N) : n

THE LARGEST ELEMENT OF THE ARRAY IS : 25

PREFIX AND SUFFIX 

#include<iostream.h>

#include<conio.h>

void main()

{ int num;

void suffix(int);

void prefix(int);

clrscr();

cin>>num;

prefix(num);

suffix(num);

getch();

}

void prefix(int n)

{

cout<<"\n"<<++n;

cout<<"\n"<<--n;

}

void suffix(int n)

{

cout<<"\n"<<n++;

cout<<"\n"<<n--;

}

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 258/400

OUTPUT

18

19

18

18

19

TO INVOKE A FUNCTION FOR PRINTING PYRAMIDS OF DIGITS 

#include<iostream.h>

#include<conio.h>

void pyramid()

{ static int n=0;

int p, m ,q;

n++;

for(p=1;p<=n;p++)

{

for(q=0;q<=n-p;q++)

cout<<' ';

m=p;

for(q=1;q<=p;q++)

cout<<m++<<' ';

cout<<endl;

}

cout<<endl;

}

void main()

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 259/400

{

int i;

clrscr();

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

pyramid();

}

OUTPUT

1

1

2 3

1

2 3

3 4 5

1

2 3

3 4 5

4 5 6 7

1

2 3

3 4 5

4 5 6 7

5 6 7 8 9

TO INVOKE A FUNCTION TO FIND THE LEAST COMMON DIVISOR OF TWO INTEGERS

#include<iostream.h>

#include<conio.h>

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 260/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 261/400

getch();

}

OUTPUT

ENTER 2 NUMBERS WHOSE LCD IS TO BE FOUND : 185

148

THE LCD OF GIVEN 2 NUMBERS IS : 37

TO FIND THE LCM AND HCF OF GIVEN 3 NUMBERS

#include<iostream.h>

#include<conio.h>

void lcm(int, int, int);

void hcf(int, int, int);

void main()

{

char choice;

do

{ int a,b,c;

clrscr();

cin>>a>>b>>c;

lcm(a,b,c);

hcf(a,b,c);

cout<<"\n\nDO YOU WANT TO REPEAT THE PROGRAM?(Y/N): ";

cin>>choice;

}while(choice=='Y'||choice=='y');

}

void lcm(int x,int y, int z)

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 262/400

{

long max,lcom, count, flag=0;

if(x>=y&&x>=z)

max=x;

else if(y>=x&&y>=z)

max=y;

else if(z>=x&&z>=y)

max=z;

for(count=1;flag==0;count++)

{

lcom=max*count;

if(lcom%x==0 && lcom%y==0 && lcom%z==0)

{

flag=1;

cout<<"\nTHE LCM OF "<<x<<","<<y<<","<<z<<" IS "<<lcom;

}

}

}

void hcf(int p, int q, int r)

{

int gcf=1,flag=0, count;

for(count=1; flag==0;count++)

{

if(p%count==0&&q%count==0&&r%count==0)

gcf=count;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 263/400

if(count>p&&count>q&&count>r)

{

flag=1;

cout<<"\nTHE GCF OF "<<p<<","<<q<<","<<r<<" IS "<<gcf;

}

}

}

getch();

}

TO SUM N NATURAL NUMBERS STARTING FROM A GIVEN NUMBER USING FUNCTION

#include<iostream.h>

#include<conio.h>

int summat(int first,int count);

void main()

{

clrscr();

unsigned long a, b, sum;

cout<<"\nENTER THE FIRST TERM : ";

cin>>a;

cout<<"\nHOW MANY NUMBERS ARE TO BE ADDED : ";

cin>>b;

sum=summat(a,b);

cout<<"THE SUM IS : "<<sum<<"\n";

getch();

}

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 264/400

int summat(int first,int count)

{

unsigned long i, s=0,j=first;

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

s+=j++;

return s;

}

TO ILLUSTRATE THE CALL BY VALUE METHOD OF FUNCTION INVOKING

#include<iostream.h>

#include<conio.h>

void main()

{

clrscr();

int change(int);

int original=10;

cout<<"THE ORIGINAL VALUE IS : "<<original;

cout<<"\nRETURN VALUE OF FUNCTION CHANGE() IS : "

<<change(original);

cout<<"\nTHE VALUE AFTER FUNCTION CHANGE() IS OVER : "

<< original;

getch();

}

int change(int a)

{

a=20;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 265/400

return a;

}

OUTPUT

THE ORIGINAL VALUE IS : 10

RETURN VALUE OF FUNCTION CHANGE() IS : 20

THE VALUE AFTER FUNCTION CHANGE() IS OVER : 10

TO SHOW THE HANDICAP OF CALL BY VALUE METHOD

#include<iostream.h>

#include<conio.h>

void main()

{

void swap(int,int);

int a=7, b=4;

clrscr();

cout<<"THE ORIGINAL VALUES ARE : ";

cout<<"a= " <<a<<" b= "<<b<<endl;

swap(a,b);

cout<<"THE VALUES AFTER SWAP() ARE : ";

cout<<"a= " <<a <<" b= "<<b<<endl;

getch();

}

void swap(int x, int y)

{

int temp;

temp=x;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 266/400

x=y;

y=temp;

cout<<"SWAPPED VALUES ARE : ";

cout<<"a= " << x <<" b= "<<y<<endl;

}

OUTPUT

THE ORIGINAL VALUES ARE : a= 7 b= 4

SWAPPED VALUES ARE : a= 4 b= 7

THE VALUES AFTER SWAP() ARE : a= 7 b= 4

A FUNCTION TO SHOW SPECIAL SERIES

#include<iostream.h>

#include<conio.h>

#include<math.h>

void factorial(int);

void series(int);

void main()

{

clrscr();

int num;

cout<<"ENTER NUMBER : ";

cin>>num;

series(num);

cout<<"\n\n";

factorial(num);

getch();

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 267/400

}

void factorial(int n)

{

long float i,result=0, fact=1;

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

{

fact=fact*i;

cout<<"+"<<i/fact<<"\t";

result=result+(i/fact);

}

cout<<"\t="<<result;

}

void series(int n)

{

long count, res=0;

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

{

cout<<"+"<<pow(n,count)<<"\t";

res=res+pow(n,count);

}

cout<<"\t="<<res;

}

OUTPUT

ENTER NUMBER : 5

+1 +5 +25 +125 +625 +3125 =3906

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 268/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 269/400

OUTPUT

THE ORIGINAL VALUES ARE : a= 7 b= 9

THE SWAPPED VALUES ARE : a= 9 b= 7

THE VALUES AFTER SWAP() ARE : a= 9 b= 7

TO CONVERT DISTANCE IN FEET OR INCHES USING A CALL BY REFERNCE METHOD

#include<iostream.h>

#include<conio.h>

#include<process.h>

void main()

{ void convert(float &, char &, char);

float distance;

char choice, type='F';

clrscr();

cout<<"\nENTER DISTANCE IN FEET : ";

cin>>distance;

cout<<"\nYOU WANT THE DISTANCE IN FEETS OR INCHES ? (F/I) : ";

cin>>choice;

switch(choice)

{

case 'f':

case 'F': convert(distance,type,'F');

break;

case 'i':

case 'I': convert(distance, type,'I');

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 270/400

break;

default: cout<<"\nYOU ENTERED A WRONG CHOICE!!!";

exit(0);

}

cout<<"\nDISTANCE = " <<distance<<" " << type << "\n";

getch();

}

void convert(float &d, char &t, char ch)

{

switch(ch)

{

case 'F': if(t=='I')

{

d=d/12;

t='F';

}

break;

case 'I': if(t=='F')

{

d=d*12;

t='I';

}

break;

}

}

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 271/400

OUTPUT

ENTER DISTANCE IN FEET : 25

YOU WANT THE DISTANCE IN FEETS OR INCHES ? (F/I) : i

DISTANCE = 300 I

TO SET LARGER OF THE GIVEN INTEGER TO -1 USING CALL BY REFERENCE 

#include<iostream.h>

#include<conio.h>

void setlarge(int &a,int &b)

{

if(a>b)

{

cout<<"\n"<<a<<" IS LARGER AND IS SET TO -1.";

a=-1;

cout<<"\nTHE NEW VALUES ARE : "<<a<<"\t"<<b;

}

else

{

cout<<"\n"<<b<<" IS LARGER AND IS SET TO -1.";

b=-1;

cout<<"\nTHE NEW VALUES ARE : "<<a<<"\t"<<b;

}

}

void main()

{

int a,b;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 272/400

clrscr();

cout<<"ENTER TWO NUMBER : "<<endl;

cin>>a>>b;

setlarge(a,b);

getch();

}

OUTPUT

ENTER TWO NUMBER :

34

45

45 IS LARGER AND IS SET TO -1.

THE NEW VALUES ARE : 34 -1

TO INVOKE A FUNCTION TAKING NO ARGUMENTS AND RETURNING NO VALUE

#include<iostream.h>

#include<string.h>

#include<conio.h>

void func(void);

void main()

{ clrscr();

func();

getch();

}

void func(void)

{ char name[25];

cout<<"\nENTER YOUR NAME : ";

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 273/400

cin.getline(name,25);

int len=strlen(name);

cout.write("HELLO ",7).write(name,len);

return;

getch();

}

TO INVOKE A FUNCTION THAT TAKES TWO INTEGERS AND AN ARITHMETIC OPERATOR THEN

DISPLAYS THE CORRESPONDING RESULT.

#include<iostream.h>

#include<conio.h>

#include<process.h>

void main()

{ clrscr();

void calc(int,int, char);

int a,b;

char ch;

cout<<"\nENTER TWO INTEGERS : "<<endl;

cin>>a>>b;

cout<<"\nENTER ATHE ARITHMETIC OPERATOR (+,-,*,%) : \n";

cin>>ch;

calc(a,b,ch);

getch();

}

void calc(int x, int y, char c)

{

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 274/400

switch(c)

{

case '+': cout<<"\nSUM OF " <<x<<" AND "<<y<< " IS " <<(x+y);

break;

case '-': cout<<"\nDIFFERENCE OF " <<x<<" AND " << y;

cout<<" IS " << (x+y);

break;

case '*': cout<<"\nPRODUCT OF " <<x<<" AND "<<y;

cout<<" IS "<<(x*y);

break;

case '/': if(x<y)

{

cout<<"\nFIRST INTEGER SHOULD BE ";

cout<<"GREATER THAN THE SECOND.";

exit(0);

}

cout<<"\nQUOTIENT " <<x<<" / " <<y<<" IS "<<(x/y);

break;

case '%': if(x<y)

{

cout<<"\nFIRST INTEGER SHOULD BE ";

cout<<"GREATER THAN THE SECOND.";

exit(0);

}

cout<<"\nREMAINDER : "<<x<<" % " <<y<<" IS "<<(x%y);

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 275/400

break;

default : cout<<"\nWRONG OPERATOR!!!";

break;

}

return;

}

TO SORT AN INTEGER ARRAY USING FUNCTION

#include<iostream.h>

#include<conio.h>

void sort(int num[], int size)

{ int swap=1, temp;

do

{

swap=0;

for(int i=0;i<size-1;i++)

{

if(num[i]>num[i+1])

{

temp=num[i];

num[i]=num[i+1];

num[i+1]=temp;

swap=1;

}

}

}while(swap==1);

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 276/400

cout<<"\n";

}

void main()

{

void sort(int[],int s);

int n[100], s=10, temp, count;

clrscr();

cout<<"\nENTER 10 NUMBERS FOR AN ARRAY TO BE SORTED :\n";

for(count=0;count<s;count++)

cin>>n[count];

temp=count;

sort(n,count);

for(count=0;count<temp;count++)

cout<<n[count]<<"\t";

getch();

}

OUTPUT

ENTER 10 NUMBERS FOR AN ARRAY TO BE SORTED :

98

56

768

435

43

54

3245

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 277/400

56

45

67

43 45 54 56 56 67 98 435 768 3245

STUDENT MARKSHEET USING FUNCTIONS 

#include<iostream.h>

#include<conio.h>

void main()

{ nt getdata(void);

float calcperc(int,int,int);

void printresults(int,int,int,float,char);

char calcgrade(float);

int m1,m2,m3,tot;

float perc;

char grade;

clrscr();

m1=getdata();

m2=getdata();

m3=getdata();

perc=calcperc(m1,m2,m3);

grade=calcgrade(perc);

printresults(m1,m2,m3,perc,grade);

getch();

}

int getdata(void)

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 278/400

{ int marks;

void err_msg(void);

do

{

cout<<"ENTER MARKS : ";

cin>>marks;

if(marks<0||marks>100)

err_msg();

}while(marks<0||marks>100);

return marks;

}

void err_msg(void)

{

cout<<"MARKS ARE OUT OF 100"<<endl;

cout<<"\nPLEASE ENTER MARKS BETWEEN 0 TO 100";

cout<<"\nTRY AGAIN";

getch();

}

float calcperc(int s1,int s2,int s3)

{

float per;

per=(s1+s2+s3)/3;

return per;

}

char calcgrade(float per)

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 279/400

{

char grade;

if(per>80)

grade='A';

else if(per>60)

grade='B';

else if (per>40)

grade='C';

else

grade='D';

return grade;

}

void printresults(int s1,int s2,int s3,float p,char g)

{

cout<<"MARKS IN SUBJECT 1 : "<<s1;

cout<<"\nMARKS IN SUBJECT 2 : "<<s2;

cout<<"\nMARKS IN SUBJECT 3 : "<<s3;

cout<<"\nPERCENTAGE SCORE : " << p;

cout<<"\nGRADE SECURED : "<<g;

}

OUTPUT

ENTER MARKS : 98

ENTER MARKS : 89

ENTER MARKS : 78

MARKS IN SUBJECT 1 : 98

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 280/400

MARKS IN SUBJECT 2 : 89

MARKS IN SUBJECT 3 : 78

PERCENTAGE SCORE : 88

GRADE SECURED : A

PALINDROME STRING 

#include<iostream.h>

#include<conio.h>

#include<string.h>

void main()

{ char ch[10];

int scount,ocount,read=1, len;

clrscr();

cout <<"ENTER A WORD : ";

cin>>ch;

len=strlen(ch);

for(scount=1, ocount=len; scount<=len/2 || ocount>=len/2; scount++, ocount--)

{

if(ch[scount]!=ch[ocount])

read=0;

}

if(read==1)

cout<<"YES! THE WORD IS PALINDROME.";

else

cout<<"NO! THE WORD IS NOT PALINDROME.";

getch();

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 281/400

}

FIND CHARACTER POSITION IN A STRING 

#include<iostream.h>

#include<conio.h>

void main()

{

clrscr();

int findpos(char s[],char c);

char string[80],ch;

int y=0;

cout<<"\nENTER MAIN STRING :\n";

cin.getline(string, 80);

cout<<"\nENTER CHARACTER TO BE SEARCH FOR : ";

cin.get(ch);

y=findpos(string,ch);

if(y==-1)

cout<<"\nSORRY!! THE CHARACTER IS NOT IN STRING.";

getch();

}

int findpos(char s[], char c)

{

int flag=-1;

for(int i=0; s[i]!='\0';i++)

{

if(s[i]==c)

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 282/400

{

flag=0;

cout<<"\nTHE CHARACTER IN THE STRING IS AT POSITION : "<<i+1;

}

}

return (flag);

}

OUTPUT

ENTER MAIN STRING :

RACHIT IS WATCHING A FREE ZEBRA IN THE PARK

ENTER CHARACTER TO BE SEARCH FOR : Z

THE CHARACTER IN THE STRING IS AT POSITION : 27

PROGRAM TO FINDWHETHER TWO STRINGS CONTAIN EQUAL NUMBER OF CHARACTERS.

#include<iostream.h>

#include<conio.h>

#include<string.h>

void main()

{ char str1[50], str2[50];

clrscr();

cout<<"ENTER THE FIRST STRING : ";

cin.getline(str1, 49);

cout<<"ENTER THE SECOND STRING : ";

cin.getline(str2, 49);

if(strlen(str1)==strlen(str2))

{

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 283/400

cout<<"\nBOTH STRINGS CONTAIN EQUAL NUMBER OF CHARACTERS.";

}

else

{

cout<<"\nBOTH STRINGS CONTAIN DIFFERENT NUMBER OF CHARACTERS.";

}

getch();

}

OUTPUT

ENTER THE FIRST STRING : GOOD EVENING

ENTER THE SECOND STRING : GOOD MORNING

BOTH STRINGS CONTAIN EQUAL NUMBER OF CHARACTERS.

ENTER THE FIRST STRING : HELLO! CAN I SPEAK TO RAM

ENTER THE SECOND STRING : OF COURSE! HERE HE IS..

BOTH STRINGS CONTAIN DIFFERENT NUMBER OF CHARACTERS.

CHECK WHETHER A CHARACTER IS ALPHANUMETRIC OR NOT

#include<iostream.h>

#include<conio.h>

#include<stdlib.h>

#include<ctype.h>

void main()

{ clrscr();

char ch;

int a;

cout<<"ENTER A CHARACTER : ";

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 284/400

cin>>ch;

a=ch;

if(isalnum(a))

{

cout<<"\nIT IS AN ALPHANUMERIC ";

if(isdigit(a))

cout<<"AND DIGIT CHARACTER. ";

else

cout<<"AND ALPHABETIC CHARACTER.";

}

else

cout<<"\nIT IS SOME OTHER NON-ALPHANUMERIC CHARACTER.";

getch();

}

OUTPUT

ENTER A CHARACTER : R

IT IS AN ALPHANUMERIC AND ALPHABETIC CHARACTER.

ENTER A CHARACTER : 7

IT IS AN ALPHANUMERIC AND DIGIT CHARACTER.

ENTER A CHARACTER : %

IT IS SOME OTHER NON-ALPHANUMERIC CHARACTER.

CHANGE THE CASE OF A CHARACTER

#include<iostream.h>

#include<conio.h>

#include<stdio.h>

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 285/400

#include<ctype.h>

void main()

{ clrscr();

char ch;

cout<<"\nENTER A CHARACTER : ";

cin>>ch;

if(ch=='\n')

{ ch=getchar(); }

if(isalpha(ch))

{ if(islower(ch))

{

cout<<"\nYOU INPUT A LOWERCASE ALPHABET.";

ch=ch-32;

cout<<"\n\nTHE UPPERCASE ALPHABET IS : "<<ch;

}

else if(isupper(ch))

{

cout<<"\nYOU INPUT AN UPPERCASE LETTER.";

ch=ch+32;

cout<<"\n\nTHE LOWERCASE ALPHABET IS : "<<ch;

}

}

else

cout<<"\nYOU INPUT A NON-ALPHABETICAL CHARACTER.";

getch();

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 286/400

}

OUTPUT

ENTER A CHARACTER : R

YOU INPUT AN UPPERCASE LETTER.

THE LOWERCASE ALPHABET IS : r

ENTER A CHARACTER : r

YOU INPUT A LOWERCASE ALPHABET.

THE UPPERCASE ALPHABET IS : R

COPY SMALLER STRING INTO THE BIGGER STRING

#include<iostream.h>

#include<conio.h>

#include<string.h>

void main()

{ clrscr();

char str1[50], str2[50];

int len1, len2;

cout<<"\nENTER THE FIRST STRING: \n";

cin.getline(str1, 50);

cout<<"\nENTER THE SECOND STRING :\n";

cin.getline(str2, 50);

if(strlen(str1)>strlen(str2))

{

strcpy(str1, str2);

cout<<"\nSECOND STRING IS COPIED INTO THE FIRST STRING. \n";

cout<<str1;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 287/400

}

else if(strlen(str2)>strlen(str1))

{

strcpy(str2,str1);

cout<<"\nFIRST STRING IS COPIED INTO THE SECOND STRING.\n";

cout<<str2;

}

else if(strlen(str1)==strlen(str2))

{

cout<<"\nSTRINGS ARE OF EQUAL SIZE. \n";

cout<<"\nSTRING1 IS : ";

cout<<str1;

cout<<"\nSTRING2 IS : ";

cout<<str2;

}

getch();

}

OUTPUT

ENTER THE FIRST STRING:

RACHIT IS GOING TO SCHOOL

ENTER THE SECOND STRING :

KHUSHAL IS GOING FOR MATCH

FIRST STRING IS COPIED INTO THE SECOND STRING.

RACHIT IS GOING TO SCHOOL

APPEND THE FIRST STRING TO THE SECOND 

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 288/400

#include<iostream.h>

#include<conio.h>

#include<string.h>

void main()

{ clrscr();

char str1[25], str2[50];

cout<<"\nENTER FIRST STRING : ";

cin.getline(str1, 25);

cout<<"\nENTER THE SECOND STRING : ";

cin.getline(str2, 25);

strcat(str2, str1);

cout<<"\n"<<str2;

getch();

}

OUTPUT

ENTER FIRST STRING : MORNING

ENTER THE SECOND STRING : GOOD

GOOD MORNING

ENTER FIRST STRING : AGRAWAL

ENTER THE SECOND STRING : ABHISHEK

ABHISHEK AGRAWAL

TO JUSTIFY A GIVEN STRING

#include<iostream.h>

#include<conio.h>

char str1[80],str2[80];

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 289/400

int count1=0,count2=0,count3=0,count4=0,count5=0, count=0;

void white_spaces(char a[]);

void justify(int);

void main()

{ clrscr();

cout<<"ENTER A STRING : ";

cin.getline(str1, 80);

white_spaces(str1);

 justify(count4);

cout<<"\nTHE JUSTIFIED STATEMENT IS :\n";

for(count=0;count<80;count++)

cout<<str2[count];

getch();

}

void white_spaces(char a[])

{

for(count=0;count<80;count++)

{

if(a[count]==' ')

count1++;

else

count2++;

if(a[count]=='\0')

{

count3=80-count2-count1;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 290/400

break;

}

}

count4=count3/count1;

}

void justify(int b)

{

for(count=0, count1=0;count1<80;count++, count1++)

{

str2[count1]=str1[count];

if(str1[count]==' ')

{

for(count5=0;count5<b;count5++)

{

count1++;

str2[count1]=' ';

}

}

}

}

EMPLOYEE DATABASE USING ARRAYS 

#include<iostream.h>

#include<conio.h>

#include<string.h>

void main()

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 291/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 292/400

swap=0;

for(count=0;count<(emp-1);count++)

{

if(eno[count]>eno[count+1])

{

temp=eno[count];

eno[count]=eno[count+1];

eno[count+1]=temp;

strcpy(tempn[count],name[count]);

strcpy(name[count],name[count+1]);

strcpy(name[count+1],tempn[count]);

temp=comm[count];

comm[count]=comm[count+1];

comm[count+1]=temp;

swap=1;

temp=grade[count];

grade[count]=grade[count+1];

grade[count+1]=temp;

}

}

}while(swap==1);

cout<< "EMPLOYEE DETAILS: "<<endl<<endl;

cout<< "\nNAME\t\tNUMBER\t\tGRADE\t\tCOMMISSION"<<endl<<endl;

for(count=0;count<emp;count++)

{

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 293/400

cout<<name[count]<<"\t\t"<<eno[count]<<"\t\t";

cout<<grade[count]<<"\t\t"<<comm[count]<<endl<<endl;

}

getch();

}

OUTPUT

ENTER THE NUMBER OF EMPLOYEES FOR DATABASE : 5

ENTER EMPLOYEE NAME : RAM

ENTER EMPLOYEE NUMBER : 7

ENTER EMPLOYEE COMMISSION : 636363

ENTER EMPLOYEE NAME : PRASAD

ENTER EMPLOYEE NUMBER : 10

ENTER EMPLOYEE COMMISSION : 45983

ENTER EMPLOYEE NAME : VINAY

ENTER EMPLOYEE NUMBER : 35

ENTER EMPLOYEE COMMISSION : 37945

ENTER EMPLOYEE NAME : JAY

ENTER EMPLOYEE NUMBER : 3

ENTER EMPLOYEE COMMISSION : 27000

ENTER EMPLOYEE NAME : BARNIK

ENTER EMPLOYEE NUMBER : 12

ENTER EMPLOYEE COMMISSION : 19875

EMPLOYEE DETAILS:

NAME NUMBER GRADE COMMISSION

JAY 3 C 27000

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 294/400

RAM 7 A 636363

PRASAD 10 B 45983

BARNIK 12 D 19875

VINAY 35 C 37945

A HOTEL FOOD BILLING PROGRAM.

#include<iostream.h>

#include<conio.h>

#include<string.h>

//VARIABLES USED

int choice, bill=0, r1, r2, r3, count=0, prod=0;

char rachit[50]; char items[50][50];

//FUNCTIONS DECLARATIONS

void copyright();

void border();

void entry();

void hello();

void menu();

void bil(int);

//MAIN PROGRAM

void main()

{

entry();

do

{

menu();

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 295/400

gotoxy(7,43);

cout<<"ENTER YOUR CHOICE : ";

cin>>choice;

while(choice<0||choice>31)

{

gotoxy(7,45);

cout<<"INVALID ENTRY. PLEASE RE-ENTER YOUR CHOICE : ";

cin>>choice;

}

switch(choice)

{

case 1:bill+=25; hello(); break;

case 2:bill+=45; hello(); break;

case 3:bill+=30; hello(); break;

case 4:bill+=35; hello(); break;

case 5:bill+=40; hello(); break;

case 6:bill+=45; hello(); break;

case 7:bill+=25; hello(); break;

case 8:bill+=35; hello(); break;

case 9:bill+=40; hello(); break;

case 10:bill+=10; hello(); break;

case 11:bill+=45; hello(); break;

case 12:bill+=45; hello(); break;

case 13:bill+=10; hello(); break;

case 14:bill+=20; hello(); break;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 296/400

case 15:bill+=25; hello(); break;

case 16:bill+=15; hello(); break;

case 17:bill+=20; hello(); break;

case 18:bill+=20; hello(); break;

case 19:bill+=20; hello(); break;

case 20:bill+=25; hello(); break;

case 21:bill+=40; hello(); break;

case 22:bill+=20; hello(); break;

case 23:bill+=35; hello(); break;

case 24:bill+=40; hello(); break;

case 25:bill+=35; hello(); break;

case 26:bill+=35; hello(); break;

case 27:bill+=15; hello(); break;

case 28:bill+=40; hello(); break;

case 29:bill+=45; hello(); break;

case 30:bill+=45; hello(); break;

default: bill+=0;

}

prod++;

}while(choice>0 && choice<31);

bil(prod);

copyright();

}

void border()

{

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 297/400

for(r3=3; r3<=79; r3++)

{

gotoxy(r3,1);

cout<<"*";

gotoxy(r3,50);

cout<<"*";

}

for(r1=0, r2=1; r1<50; r1++, r2++)

{

gotoxy(3,r2);

cout<<"*";

gotoxy(79,r2);

cout<<"*";

}

}

void copyright()

{

getch();

clrscr();

border();

gotoxy(22,18);

cout << "PROGRAM EXCLUSIVELY CREATED BY :";

gotoxy(30,20);

cout << "RACHIT AGRAWAL";

gotoxy(20,22);

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 298/400

cout << "EMAIL: rachit_agrawal9@gmail.com";

gotoxy(15,24);

cout << "PROGRAM TO BE DISTRIBUTED FREELY AS SHAREWARE.";

gotoxy(25,26);

cout << "PROGRAM CODE NOT TO BE MODIFIED.";

gotoxy(10,28);

cout << "MODIFICATIONS WITHOUT HIS PRIOR PERMISSION INVITE LEGAL ACT.";

gotoxy(15,30);

cout << "SUGGESTIONS AND COMMENTS WILL BE APRRECIATED AT

chand4202002@yahoo.com";

gotoxy(25,32);

cout << "THANK YOU "<<rachit<<" FOR USING THE PROGRAM. ";

gotoxy(27,34);

cout << "HAVE A PROGRESSIVE DAY! ";

getch();

}

void entry()

{

clrscr();

cout<<"\nWELCOME!!!WELCOME!!!\n\nTO THE MOST PRESTIGIOUS RESTAURANT.\

\n'THE AFFORDABLES''!!!";

for(r3=7; r3<=73; r3++)

{

gotoxy(r3,16);

cout<<"*";

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 299/400

gotoxy(r3,22);

cout<<"*";

}

for(r1=0, r2=17; r1<=4; r1++, r2++)

{

gotoxy(7,r2);

cout<<"*";

gotoxy(73,r2);

cout<<"*";

}

gotoxy(9,19);

cout << "PLEASE ENTER YOUR NAME : ";

cin.getline ( rachit, 24);

}

void hello()

{

switch(choice)

{

case 1: strcpy(items[count],"BHEL PURI\t\t25");break;

case 2: strcpy(items[count],"BHAJI PAV\t\t45");break;

case 3: strcpy(items[count],"CASSATA\t\t30");break;

case 4: strcpy(items[count],"COLD COFFEE\t\t35");break;

case 5: strcpy(items[count],"CHOCO DRIP SHAKE\t40");break;

case 6: strcpy(items[count],"CHIKOO SHAKE\t\t45");break;

case 7: strcpy(items[count],"DOUGHNUTS\t\t25");break;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 300/400

case 8: strcpy(items[count],"DELHI CHAT\t\t35");break;

case 9: strcpy(items[count],"FALUDA KULFI\t\t40");break;

case 10:strcpy(items[count],"GULAB JAMUN\t10");break;

case 11:strcpy(items[count],"HAKKA NOODLES\t45");break;

case 12:strcpy(items[count],"HAM BURGER\t\t45");break;

case 13:strcpy(items[count],"IMARTI\t\t10");break;

case 14:strcpy(items[count],"INDIAN SHARBAT\t20");break;

case 15:strcpy(items[count],"JAPANESE JEMS\t25");break;

case 16:strcpy(items[count],"KACHORI\t\t15");break;

case 17:strcpy(items[count],"KINLEYS SODA\t20");break;

case 18:strcpy(items[count],"MASALA PARATHA\t20");break;

case 19:strcpy(items[count],"MASALA PAPAD\t20");break;

case 20:strcpy(items[count],"MANGO SHAKE\t25");break;

case 21:strcpy(items[count],"NAVRATNA KORMA\t40");break;

case 22:strcpy(items[count],"PANI PURI\t\t20");break;

case 23:strcpy(items[count],"PASTA\t\t35");break;

case 24:strcpy(items[count],"PIZZA\t\t40");break;

case 25:strcpy(items[count],"RASMALAI\t\t35");break;

case 26:strcpy(items[count],"RAJBHOG ICE-CREAM\t35");break;

case 27:strcpy(items[count],"SAMOSA\t\t15");break;

case 28:strcpy(items[count],"SWEET CORN SOUP\t40");break;

case 29:strcpy(items[count],"SPEGGATI\t\t45");break;

case 30:strcpy(items[count],"TOMATO SOUP\t45");break;

}

count++;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 301/400

}

void menu()

{

clrscr(); border();

gotoxy(7,4);

cout << "WELCOME " << rachit;

gotoxy(7,6);

cout<<"DELICACIES\tPRICE";

gotoxy(7,8);

cout<<"1 BHEL PURI\t\t25";

gotoxy(7,9);

cout<<"2 BHAJI PAV\t\t45";

gotoxy(7,10);

cout<<"3 CASSATA\t\t30";

gotoxy(7,11);

cout<<"4 COLD COFFEE\t\t35";

gotoxy(7,12);

cout<<"5 CHOCO DRIP SHAKE\t40";

gotoxy(7,13);

cout<<"6 CHIKOO SHAKE\t45";

gotoxy(7,14);

cout<<"7 DOUGHNUTS\t\t25";

gotoxy(7,15);

cout<<"8 DELHI CHAT\t\t35";

gotoxy(7,16);

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 302/400

cout<<"9 FALUDA KULFI\t40";

gotoxy(7,17);

cout<<"10 GULAB JAMUN\t10";

gotoxy(7,18);

cout<<"11 HAKKA NOODLES\t45";

gotoxy(7,19);

cout<<"12 HAM BURGER\t\t45";

gotoxy(7,20);

cout<<"13 IMARTI\t\t10";

gotoxy(7,21);

cout<<"14 INDIAN SHARBAT\t20";

gotoxy(7,22);

cout<<"15 JAPANESE JEMS\t25";

gotoxy(7,23);

cout<<"16 KACHORI\t\t15";

gotoxy(7,24);

cout<<"17 KINLEYS SODA\t20";

gotoxy(7,25);

cout<<"18 MASALA PARATHA\t20";

gotoxy(7,26);

cout<<"19 MASALA PAPAD\t20";

gotoxy(7,27);

cout<<"20 MANGO SHAKE\t25";

gotoxy(7,28);

cout<<"21 NAVRATNA KORMA\t40";

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 303/400

gotoxy(7,29);

cout<<"22 PANI PURI\t\t20";

gotoxy(7,30);

cout<<"23 PASTA\t\t35";

gotoxy(7,31);

cout<<"24 PIZZA\t\t40";

gotoxy(7,32);

cout<<"25 RASMALAI\t\t35";

gotoxy(7,33);

cout<<"26 RAJBHOG ICE-CREAM\t35";

gotoxy(7,34);

cout<<"27 SAMOSA\t\t15";

gotoxy(7,35);

cout<<"28 SWEET CORN SOUP\t40";

gotoxy(7,36);

cout<<"29 SPEGGATI\t\t45";

gotoxy(7,37);

cout<<"30 TOMATO SOUP\t45";

gotoxy(7,38);

cout<<"31 FINAL BILL";

gotoxy(7,40);

cout<<"ENTER THE FOOD ITEM ORDERED FROM THE ABOVE MENU.";

gotoxy(7,41);

cout<<"ENTER 31 FOR THE FINAL BILL OF THE CUSTOMER.";

}

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 304/400

void bil(int prod)

{

int temp; clrscr();

for(temp=0;temp<prod;temp++)

cout<<items[temp]<<endl;

cout<<"DEAR "<<rachit<<"!!\n YOUR FINAL BILL IS : "<<bill <<" RUPEES";

cout<<"\nTHANKS FOR COMING. PLEASE VISIT AGAIN SOON.";

}

DECIMAL TO BINARY BY MUHAMMAD IRFAN ARSHAD 

#include<iostream.h>

#include<conio.h>

void main()

{ char choice;

do

{

clrscr();

int deci,temp[9];

cout<<"\nENTER A DECIMAL NUMBER: ";

cin>>deci;

for (int count=0;deci>=1;count++)

{

temp[count]=deci%2;

deci=deci/2;

}

for(count--;count>=0;count--)

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 305/400

cout<<temp[count];

cout<<"\nWISH TO CONTINUE?(Y/N): ";

choice=getche();

}while(choice=='y'||choice=='Y');

}

DECIMAL TO OCTAL BY MUHAMMAD IRFAN ARSHAD 

#include<iostream.h>

#include<conio.h>

void main()

{ char choice;

do

{

clrscr();

int deci,temp[9];

cout<<"\nENTER A DECIMAL NUMBER: ";

cin>>deci;

for (int count=0;deci>=1;count++)

{

temp[count]=deci%8;

deci=deci/8;

}

for(count--;count>=0;count--)

cout<<temp[count];

cout<<"\nWISH TO CONTINUE?(Y/N): ";

choice=getche();

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 306/400

}while(choice=='y'||choice=='Y');

}

DECIMAL TO HEXADECIMAL BY RACHIT AGRAWAL 

#include<iostream.h>

#include<conio.h>

void main()

{ char choice;

do

{ clrscr();

long deci,temp[9];

char result[9]={0};

cout<<"\nENTER A DECIMAL NUMBER: ";

cin>>deci;

for (int count=0;deci>=1;count++)

{

temp[count]=deci%16;

deci=deci/16;

if(temp[count]>9)

{

switch(temp[count])

{

case 10:result[count]='A';

break;

case 11:result[count]='B';

break;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 307/400

case 12:result[count]='C';

break;

case 13:result[count]='D';

break;

case 14:result[count]='E';

break;

case 15:result[count]='F';

break;

}

}

else

{

result[count]=temp[count]+48;

}

}

cout<<"\n";

for(count=count-1; count>=0;count--)

cout<<result[count];

cout<<"\nWISH TO CONTINUE?(Y/N): ";

choice=getch();

}while(choice=='y'||choice=='Y');

}

BINARY TO DECIMAL 

#include<iostream.h>

#include<conio.h>

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 308/400

#include<math.h>

void main()

{ clrscr();

int bin, digit, a=0, deci=0;

cout<<"\nENTER A BINARY NUMBER : ";

cin>>bin;

for(int count=0;bin>=1;count++)

{

digit=bin%10;

while(digit>1)

{

cout<<"\nOOPS!!! ERROR. RE-ENTER : ";

cin>>bin;

digit=bin%10;

}

a=digit*pow(2,count);

deci+=a;

bin/=10;

}

cout<<"\nTHE DECIMAL NUMBER IS : "<<deci;

getch();

}

BINARY TO OCTAL 

#include<iostream.h>

#include<conio.h>

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 309/400

#include<math.h>

void main()

{

clrscr();

int bin, digit, a=0, deci=0, octa[9];;

cout<<"\nENTER A BINARY NUMBER : ";

cin>>bin;

for(int count=0;bin>=1;count++)

{

digit=bin%10;

while(digit>1)

{

cout<<"\nOOPS!!! ERROR. RE-ENTER : ";

cin>>bin;

digit=bin%10;

}

a=digit*pow(2,count);

deci+=a;

bin/=10;

}

for (count=0;deci>=1;count++)

{

octa[count]=deci%8;

deci=deci/8;

}

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 310/400

for(count--;count>=0;count--)

cout<<octa[count];

getch();

}

BINARY TO HEXADECIMAL 

#include<iostream.h>

#include<conio.h>

#include<math.h>

void main()

{ clrscr();

int bin, digit, a=0, deci=0,long temp[9]; char result[9];

cout<<"\nENTER A BINARY NUMBER : ";

cin>>bin;

for(int count=0;bin>=1;count++)

{

digit=bin%10;

while(digit>1)

{

cout<<"\nOOPS!!! ERROR. RE-ENTER : ";

cin>>bin;

digit=bin%10;

}

a=digit*pow(2,count);

deci+=a;

bin/=10;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 311/400

}

for (count1=0;deci>=1;count1++)

{

temp[count1]=deci%16;

deci=deci/16;

if(temp[count1]>9)

{

switch(temp[count1])

{

case 10:result[count1]='A';

break;

case 11:result[count1]='B';

break;

case 12:result[count1]='C';

break;

case 13:result[count1]='D';

break;

case 14:result[count1]='E';

break;

case 15:result[count1]='F';

break;

}

}

else

{ result[count1]=temp[count1]+48; }

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 312/400

}

cout<<"\n";

for(count=count-1; count>=0;count--)

cout<<result[count];

getch();

}

OCTAL TO DECIMAL 

#include<iostream.h>

#include<conio.h>

#include<math.h>

void main()

{ clrscr();

int oct, digit, a=0, deci=0;

cout<<"\nENTER A OCTAL NUMBER : ";

cin>>oct;

for(int count=0;oct>=1;count++)

{ digit=oct%10;

while(digit>7)

{ cout<<"\nOOPS!!! ERROR. RE-ENTER : ";

cin>>oct;

digit=oct%10; }

a=digit*pow(8,count);

deci+=a;

oct/=10; }

cout<<"\nTHE DECIMAL NUMBER IS : "<<deci;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 313/400

getch();

}

OCTAL TO BINARY 

#include<iostream.h>

#include<conio.h>

#include<math.h>

void main()

{ clrscr();

int oct, digit, a=0, deci=0;

cout<<"\nENTER A OCTAL NUMBER : ";

cin>>oct;

for(int count=0;oct>=1;count++)

{ digit=oct%10;

while(digit>7)

{ cout<<"\nOOPS!!! ERROR. RE-ENTER : ";

cin>>oct;

digit=oct%10; }

a=digit*pow(8,count);

deci+=a;

oct/=10; }

int temp[9];

for (count=0;deci>=1;count++)

{ temp[count]=deci%2;

deci=deci/2; }

for(count--;count>=0;count--)

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 314/400

cout<<temp[count];

getch();

}

OCTAL TO HEXADECIMAL 

#include<iostream.h>

#include<conio.h>

#include<math.h>

void main()

{ clrscr();

long oct, digit, a=0, deci=0,temp[9];;

cout<<"\nENTER A OCTAL NUMBER : ";

cin>>oct;

for(int count=0;oct>=1;count++)

{ digit=oct%10;

while(digit>7)

{ cout<<"\nOOPS!!! ERROR. RE-ENTER : ";

cin>>oct;

digit=oct%10; }

a=digit*pow(8,count);

deci+=a;

oct/=10; }

char result[9]={0};

for (count=0;deci>=1;count++)

{ temp[count]=deci%16;

deci=deci/16;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 315/400

if(temp[count]>9)

{ switch(temp[count])

{ case 10:result[count]='A';

break;

case 11:result[count]='B';

break;

case 12:result[count]='C';

break;

case 13:result[count]='D';

break;

case 14:result[count]='E';

break;

case 15:result[count]='F';

break;

}

}

else

{ result[count]=temp[count]+48; }

}

cout<<"\n";

for(count=count-1; count>=0;count--)

cout<<result[count];

getch();

}

//HEXADECIMAL TO DECIMAL 

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 316/400

#include<iostream.h>

#include<conio.h>

#include<stdlib.h>

#include<math.h>

#include<ctype.h>

#include<process.h>

void main()

{

clrscr();

char hex[8];

long temp[8],sum=0;

cin>>hex;

for(int i=0;hex[i]!='\0';i++)

{ if(isdigit(hex[i]))

temp[i]=hex[i]-48;

else if(isalpha(hex[i]))

{ switch(hex[i])

{

case 'A':temp[i]=10;break;

case 'B':temp[i]=11;break;

case 'C':temp[i]=12;break;

case 'D':temp[i]=13;break;

case 'E':temp[i]=14;break;

case 'F':temp[i]=15;break;

}

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 317/400

}

}

i--;

for(int x=0;i>=0;i--, x++)

sum=sum+(temp[i]*pow(16,x));

cout<<"\n\n"<<sum;

getch();

}

HEXADECIMAL TO BINARY 

#include<iostream.h>

#include<conio.h>

#include<stdlib.h>

#include<math.h>

#include<ctype.h>

#include<process.h>

void main()

{ clrscr();

char hex[8];

long temp[8],sum=0;

cin>>hex;

for(int i=0;hex[i]!='\0';i++)

{

if(isdigit(hex[i]))

temp[i]=hex[i]-48;

else if(isalpha(hex[i]))

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 318/400

{

switch(hex[i])

{

case 'A':temp[i]=10;break;

case 'B':temp[i]=11;break;

case 'C':temp[i]=12;break;

case 'D':temp[i]=13;break;

case 'E':temp[i]=14;break;

case 'F':temp[i]=15;break;

}

}

}

i--;

for(int x=0;i>=0;i--, x++)

sum=sum+(temp[i]*pow(16,x));

long t[25];

for (int count=0;sum>=1;count++)

{

t[count]=sum%2;

sum=sum/2;

}

for(count--;count>=0;count--)

cout<<t[count];

getch();

}

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 319/400

HEXADECIMAL TO OCTAL 

#include<iostream.h>

#include<conio.h>

#include<stdlib.h>

#include<math.h>

#include<ctype.h>

#include<process.h>

void main()

{ clrscr();

char hex[8];

long temp[8],sum=0;

cin>>hex;

for(int i=0;hex[i]!='\0';i++)

{

if(isdigit(hex[i]))

temp[i]=hex[i]-48;

else if(isalpha(hex[i]))

{

switch(hex[i])

{

case 'A':temp[i]=10;break;

case 'B':temp[i]=11;break;

case 'C':temp[i]=12;break;

case 'D':temp[i]=13;break;

case 'E':temp[i]=14;break;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 320/400

case 'F':temp[i]=15;break;

}

}

}

i--;

for(int x=0;i>=0;i--, x++)

sum=sum+(temp[i]*pow(16,x));

long t[25];

for (int count=0;sum>=1;count++)

{

t[count]=sum%8;

sum=sum/8;

}

for(count--;count>=0;count--)

cout<<t[count];

getch();

}

TO TRANSLATE NUMBER INTO WORDS 

long num=0,temp=0,flag=0,flag1=0, risk=0, ge=0,g=0;

char words[200];

void unit(int);

void tns(int);

void di(int);

void hun(int);

void thous(int);

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 321/400

void dth(int);

void check(long);

void check1(long);

void main()

{ clrscr();

cout<<"\nENTER A NUMBER : ";

cin>>num;

ge=num;

check(num);

cout<<"\n\nTHE NUMBER " <<ge<<" IN WORDS IS :\n\n"<<words<<"\n\nONLY.";

for(int i=0;words[i]!='\0';i++)

strcpy(words," ");

getch();

}

void unit(int num)

{

switch(num)

{ case 0: flag1++;break;

case 1: strcat(words,"ONE ");break;

case 2: strcat(words,"TWO ");break;

case 3: strcat(words,"THREE ");break;

case 4: strcat(words,"FOUR ");break;

case 5: strcat(words,"FIVE ");break;

case 6: strcat(words,"SIX ");break;

case 7: strcat(words,"SEVEN ");break;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 322/400

case 8: strcat(words,"EIGHT ");break;

case 9: strcat(words,"NINE ");break;

}

}

void tns(int num)

{

num=num%10;

switch(num)

{

case 0: strcat(words,"TEN ");break;

case 1: strcat(words,"ELEVEN ");break;

case 2: strcat(words,"TWELVE ");break;

case 3: strcat(words,"THIRTEEN ");break;

case 4: strcat(words,"FOURTEEN ");break;

case 5: strcat(words,"FIFTEEN ");break;

case 6: strcat(words,"SIXTEEN ");break;

case 7: strcat(words,"SEVENTEEN ");break;

case 8: strcat(words,"EIGHTEEN ");break;

case 9: strcat(words,"NINETEEN ");break;

}

}

void di(int num)

{

flag=0;

switch(num)

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 323/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 324/400

else

tns(temp);

}

void thous(int num)

{

temp=num/1000;

unit(temp);

strcat(words,"THOUSAND ");

num=num%1000;

hun(num);

}

void check1(long risk)

{

if(risk>9&risk<20)

tns(risk);

else if(risk<100)

{

temp=risk/10;

di(temp);

temp=risk%10;

unit(temp);

}

}

void check(long num)

{

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 325/400

r: if(num==0)

{

strcat(words,"ZERO");

getch();

}

if(num>9&num<20)

tns(num);

else if(num<100)

{

temp=num/10;

di(temp);

temp=num%10;

unit(temp);

}

else if(num<1000)

hun(num);

else if(num<10000)

thous(num);

else if(num<100000)

{

risk=num/1000;

check1(risk);

strcat(words,"THOUSAND ");

num=num%1000;

goto r;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 326/400

}

else if(num<10000000)

{

risk=num/100000;

check1(risk);

strcat(words,"LAKHS ");

num=num%100000;

goto r;

}

else if(num<1000000000)

{

risk=num/10000000;

check1(risk);

strcat(words,"CRORES ");

num=num%10000000;

goto r;

}

}

TO DISPLAY THE CALENDAR OF A MONTH 

char day[10],choice1;

int month1=0;

int pos=0,i=0,x=1;

void m1();

void m2();

void m3();

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 327/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 328/400

else if(strcmp(day,"saturday")==0||strcmp(day,"SATURDAY")==0)

pos=7;

cout<<"\n\nSUN\tMON\tTUES\tWED\tTHURS\tFRI\tSAT\n";

check:

fcheck(pos);

if 

(month1==1||month1==3||month1==5||month1==7||month1==8||month1==10||month1==12)

m1();

else if(month1==4||month1==6||month1==9||month1==11)

m2();

else if(month1==2)

m3();

cout<<"\n\n\nPRESS N FOR THE NEXT MONTH AND P FOR THE PREVIOUS MONTH.";

cout<<"\nPRESS E EXIT\n\nYOUR CHOICE : ";

cin>>choice1;

if(choice1=='n'||choice1=='N')

{

month1++;

if(month1>12)

month1-=12;

pos=i%7;

goto check;

}

else if(choice1=='p'||choice1=='P')

{

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 329/400

month1--;

if(month1<1)

month1+=12;

pcheck();

goto check;

}

else

cout<<"\n\nTHANX FOR USING THE PROGRAM. PRESS ANY KEY TO EXIT";

getch();

}

void pcheck()

{

if 

(month1==1||month1==3||month1==5||month1==7||month1==8||month1==10||month1==12)

m4();

else if(month1==4||month1==6||month1==9||month1==11)

m5();

else if(month1==2)

m6();

pos=i;

}

void fcheck(int t)

{

if(t==2)

cout<<"\t";

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 330/400

else if(t==3)

cout<<"\t"<<"\t";

else if(t==4)

cout<<"\t"<<"\t"<<"\t";

else if(t==5)

cout<<"\t"<<"\t"<<"\t"<<"\t";

else if(t==6)

cout<<"\t"<<"\t"<<"\t"<<"\t"<<"\t";

else if(t==7)

cout<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<<"\t";

}

void m1()//m1 for type of months having 31 days

{

int count;

for(i=pos, count=1;count<=31;i++, count++)

{

cout<<count<<"\t";

if(i%7==0)

cout<<"\n";

}

}

void m2()//m2 for type of months having 30 days

{

int count;

for(i=pos, count=1;count<=30;i++, count++)

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 331/400

{

cout<<count<<"\t";

if(i%7==0)

cout<<"\n";

}

}

void m3()//m3 for type of months having 28 days

{

int count;

for(i=pos, count=1;count<=28;i++, count++)

{

cout<<count<<"\t";

if(i%7==0)

cout<<"\n";

}

}

void m4()//m4 for type of months having 31 days

{

int count;

for(i=pos, count=31;count>=1;i--, count--)

{

if(i<=0)

i=7;

}

}

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 332/400

void m5()//m2 for type of months having 30 days

{

int count;

for(i=pos, count=30;count>=1;i--, count--)

{

if(i<=0)

i=7;

}

}

void m6()//m3 for type of months having 28 days

{

int count;

for(i=pos, count=28;count>=1;i--, count--)

{

if(i<=0)

i=7;

}

}

MY BEST PROGRAMS MENU RETURN

#include<iostream.h>

#include<conio.h>

#include<stdlib.h>

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 333/400

#include<stdio.h>

#include<string.h>

#include<math.h>

#include<process.h>

#include<ctype.h>

#include<dos.h>

#include<bios.h>

void prog();

char rachit[25],t, ltype,start,namex[10][15],xname[25];

int choice, decision, r1, r2, choice1=0, num2, height, ncardleft,

num16[10], swap=1, temp1, i, num11[15],search11, count11,l, flag=0;

long num1=0, fact, gfact, fsum, num3, fact1, count1, num4, fact2, gfact1,

bdate,tempo, date, gdate, month, year, julian, fours,hundreds, four_hundreds,

day, digit2, sum, digit3,basicn, digit4, luck;

long float result, circumference, area, volume, radius, length, breadth,

count3, temp;

void check(long);

void pyramid(int);

void matrices(int);

void birth_date(long);

void border()

{

clrscr();

for(r1=3; r1<=79; r1++)

{

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 334/400

gotoxy(r1,1);

cout<<"*";

gotoxy(r1,50);

cout<<"*";

}

for(r2=1; r2<=50; r2++)

{

gotoxy(3,r2);

cout<<"*";

gotoxy(79,r2);

cout<<"*";

}

}

void copyright()

{

clrscr();

border();

gotoxy(22,18);

cout << "PROGRAM EXCLUSIVELY CREATED BY :";

gotoxy(30,20);

cout << "MUHAMMAD IRFAN ARSHAD";

gotoxy(20,22);

cout << "EMAIL: chand4202002@yahoo.com";

gotoxy(15,24);

cout << "PROGRAM TO BE DISTRIBUTED FREELY AS SHAREWARE.";

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 335/400

gotoxy(25,26);

cout << "PROGRAM CODE NOT TO BE MODIFIED.";

gotoxy(10,28);

cout << "MODIFICATIONS WITHOUT HIS PRIOR PERMISSION INVITE LEGAL

ACT.";

gotoxy(15,30);

cout << "SUGGESTIONS AND COMMENTS WILL BE APRRECIATED.";

gotoxy(25,32);

cout << "THANK YOU "<<rachit<<" FOR USING THE PROGRAM. ";

gotoxy(27,34);

cout << "HAVE A PROGRESSIVE DAY! ";

getch();

}

void entry()

{

clrscr ();

for(r1=7; r1<=73; r1++)

{

gotoxy(r1,16);

cout<<"*";

gotoxy(r1,22);

cout<<"*";

}

for( r2=17; r2<=21; r2++)

{

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 336/400

gotoxy(7,r2);

cout<<"*";

gotoxy(73,r2);

cout<<"*";

}

gotoxy(9,19);

cout << "PLEASE ENTER YOUR NAME : ";

cin.getline ( rachit, 24);

}

void hline(int x,int y,int w,char ch,int c)

{

int i;

textcolor(c);

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

{

gotoxy(x+i,y);

cout<<ch;

}

}

void vline(int x,int y,int h,char ch,int c)

{

int i;

textcolor(c);

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

{

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 337/400

gotoxy(x,y+i);

cout<<ch;

}

}

void box(int x,int y,int w,int h,char ch)

{

hline(x,y,w,ch,15);

hline(x+1,y+h-1,w,ch,15);

vline(x,y,h,ch,15);

vline(x+w,y,h,ch,15);

}

void clear(int x1,int y1,int x2,int y2)

{

int i,j;

for (i=x1;i<=x2;i++)

{

for (j=y1;j<=y2;j++)

{

gotoxy(i,j);

cout<<" ";

}

}

}

void confirm()

{

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 338/400

if (bioskey(1)!=0)

{

bioskey(0);

copyright();

prog();

}

}

void loading()

{

int i,x;

clear(1,1,80,50);

box(1,1,79,49,'*');

box(27,5,26,6,'*');

gotoxy(29,7);

cout<<"I N S T R U C T I O N S";

gotoxy(29,8);

cout<<"=======================";

box(5,20,71,9,'*');

gotoxy(7,22);

cout<<"YOU CAN EASILY MOVE THROUGH THE MENU.";

gotoxy(7,24);

cout<<"PROPER LINKS TO PROGRAMS HAVE BEEN PROVIDED.";

gotoxy(7,26);

cout<<"KINLDY COOPERATE WITH ON SCREEN MESSEGES SEPARATELY.";

box(18,40,44,3,'*');

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 339/400

gotoxy(18,39);

cout<<"LOADING PLEASE WAIT:";

int p;

for (i=1,x=19,p=16;p<=100;i++,x+=2, p+=4)

{

gotoxy(56,39);

cout<<p<<"%";

gotoxy(x,41);

cout<<">";

delay(300);

gotoxy(x,41);

cout<<"--";

confirm();

}

clrscr();

}

void main_scr()

{

char txt[100]={" R A C H I T P R E S E N T S "};

int i,x,m,n;;

box(1,1,79,49,'*');

box(5,5,71,7,'*');

for (m=25,n=8,i=0;txt[i]!=0;i++,m++)

{

gotoxy(m,n);

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 340/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 341/400

gotoxy(17,20);

cout<<" W E L C O M E !! "<<rachit;

int r;

for (r=19,i=0;txt[i]!='\0';i++) //for entry effect

{

for (x=2;x<11;x++)

{

gotoxy(x,28);

cout<<txt[i];

delay(200);

gotoxy(x,28);

cout<<txt[i];

gotoxy(x,28);

cout<<" ";

}

gotoxy(r,28);

cout<<txt[i];

r+=m;

}

for(x=0;bioskey(1)==0;x++) //for shimmering light effect

{

for (i=0,r=19;txt[i]!='\0';i++,r+=m)

{

gotoxy(r,28);

cout<<txt[i];

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 342/400

}

delay(500);

for (i=0,r=19;txt[i]!='\0';i++,r+=m)

{

gotoxy(r,28);

cout<<" ";

}

delay(300);

}

confirm();

}

void main_menu()

{

int x=7,y=4;

border();

gotoxy(x,y);y+=2;

cout << " WELCOME " << rachit <<" !! SELECT ONE PROGRAM FOR

EXECUTION : "<<endl;

gotoxy(x,y);y+=2;

cout << " 1 " << " SIMPLE CALCULATOR " << endl;

gotoxy(x,y);y+=2;

cout << " 2 " << " NUMBER DETAILS " << endl;

gotoxy(x,y);y+=2;

cout << " 3 " << " PYRAMIDS " << endl;

gotoxy(x,y);y+=2;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 343/400

cout << " 4 " << " MATRICES " << endl;

gotoxy(x,y);y+=2;

cout << " 5 " << " CARD GAME " << endl;

gotoxy(x,y);y+=2;

cout << " 6 " << " NUMEROLOGY " << endl;

gotoxy(x,y);y+=2;

cout << " 7 " << " ARRAY PROGRAMS " << endl;

gotoxy(x,y);y+=2;

cout << " 8 " << " MENSURATION " << endl;

gotoxy(x,y);y+=2;

cout << " 9 " << " NUMBER SYSTEMS " << endl;

gotoxy(x,y);y+=2;

cout << " 10 " << " EXIT " << endl;

}

void cal_menu()

{

int x=24,y=16;

gotoxy(x,y);y+=2;

cout << " CALCULATOR " << endl;

gotoxy(x,y);y+=2;

cout << " 1 " << " ADD " << endl;

gotoxy(x,y);y+=2;

cout << " 2 " << " SUBTRACT " << endl;

gotoxy(x,y);y+=2;

cout << " 3 " << " MULTIPLY " << endl;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 344/400

gotoxy(x,y);y+=2;

cout << " 4 " << " DIVIDE " << endl;

gotoxy(x,y);y+=2;

cout << " 5 " << " EXIT " << endl;

}

void num_details()

{

int x=24,y=16;

border();

gotoxy(x,y);y+=2;

cout << " NUMBER DETAILS " << endl;

gotoxy(x,y);y+=2;

cout << " 1 " << " FACTORS " << endl;

gotoxy(x,y);y+=2;

cout << " 2 " << " PERFECT NUMBER " << endl;

gotoxy(x,y);y+=2;

cout << " 3 " << " PRIME NUMBER " << endl;

gotoxy(x,y);y+=2;

cout << " 4 " << " ALL IN ONE " << endl;

gotoxy(x,y);y+=2;

cout << " 5 " << " EXIT " << endl;

}

void pyramenu()

{

b: clrscr();

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 345/400

border();

int x=7,y=6;

gotoxy(x,y);y+=2;

cout << " 1 " << " PYRAMID 1 " << endl;

gotoxy(x,y);y+=2;

cout << " 2 " << " PYRAMID 2 " << endl;

gotoxy(x,y);y+=2;

cout << " 3 " << " PYRAMID 3 " << endl;

gotoxy(x,y);y+=2;

cout << " 4 " << " PYRAMID 4 " << endl;

gotoxy(x,y);y+=2;

cout << " 5 " << " PYRAMID 5 " << endl;

gotoxy(x,y);y+=2;

cout << " 6 " << " PYRAMID 6 " << endl;

gotoxy(x,y);y+=2;

cout << " 7 " << " PYRAMID 7 " << endl;

gotoxy(x,y);y+=2;

cout << " 8 " << " PYRAMID 8 " << endl;

gotoxy(x,y);y+=2;

cout << " 9 " << " PYRAMID 9 " << endl;

gotoxy(x,y);y+=2;

cout << " 10 " << " PYRAMID 10 " << endl;

gotoxy(x,y);y+=2;

cout << " 11 " << " PYRAMID 11 " << endl;

gotoxy(x,y);y+=2;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 346/400

cout << " 12 " << " PYRAMID 12 " << endl;

gotoxy(x,y);y+=2;

cout << " 13 " << " EXIT " << endl<<endl;

int p;

gotoxy(x,y);y+=2;

cout<<"ENTER YOUR CHOICE FROM THE ABOVE MENU: ";

cin>>p;

pyramid(p);

if(p<13)

goto b;

copyright();

}

void matmenu()

{

a: clrscr();

border();

int x=7,y=6;

gotoxy(x,y);y+=2;

cout << " 1 " << " ADDITION OF TWO MATRICES " << endl;

gotoxy(x,y);y+=2;

cout << " 2 " << " SUBTRACTION OF TWO MATRICES " << endl;

gotoxy(x,y);y+=2;

cout << " 3 " << " MULTIPLICATION OF TWO MATRICES " << endl;

gotoxy(x,y);y+=2;

cout << " 4 " << " ROW SUM AND COLUMN SUM OF A MATRIX " << endl;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 347/400

gotoxy(x,y);y+=2;

cout << " 5 " << " SUM OF ELEMENTS ABOVE AND BELOW THE MAIN

DIAGONAL OF MATRIX " << endl;

gotoxy(x,y);y+=2;

cout << " 6 " << " TRANSPOSE A MATRIX " << endl;

gotoxy(x,y);y+=2;

cout << " 7 " << " EXIT " << endl;

gotoxy(x,y);y+=2;

cout<<"ENTER YOUR CHOICE FROM THE ABOVE MENU : ";

int p;

cin>>p;

if(p>7)

goto a;

else if(p==7)

{

copyright(); prog();

}

else

matrices(p);

getch();

}

void xmenu()

{

sh: clrscr();

border();

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 348/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 349/400

gotoxy(x,y);y+=2;

cout<<"13 EXIT ";

gotoxy(x,y);y+=2;

cout << "ENTER YOUR CHOICE (1 to 13) : ";

cin >> choice;

while(choice<1 || choice>13)

goto sh;

check(choice);

}

void birth_date(long bdate)

{

if(bdate>=1010000&&bdate<=31129999) // date is single and month double

{

date=bdate/1000000;

tempo=bdate%1000000;

month=tempo/10000;

year=tempo%10000;

}

else

cout<<"INVALID DATE";

}

void array_prog()

{

int x=24,y=16;

border();

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 350/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 351/400

gotoxy(x,y);y+=2;

cout<<"5 VOLUME OF SPHERE";

gotoxy(x,y);y+=2;

cout<<"6 AREA OF SQUARE";

gotoxy(x,y);y+=2;

cout<<"7 AREA OF RECTANGLE";

gotoxy(x,y);y+=2;

cout<<"8 AREA OF TRIANGLE";

gotoxy(x,y);y+=2;

cout<<"9 AREA OF CIRCLE";

gotoxy(x,y);y+=2;

cout<<"10 CIRCUMFERENCE OF CIRCLE";

gotoxy(x,y);y+=2;

cout<<"11 EXIT";

gotoxy(x,y);y+=2;

}

void simple_calculator()

{

do

{

clrscr ();

border();

cal_menu();

gotoxy(24,28);

cout << " ENTER YOUR CHOICE : ";

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 352/400

cin>>choice1;

while(choice1>5 && choice1<1)

{

clrscr();

border();

cal_menu();

gotoxy(24,28);

cout<<" INVALID CHOICE !!!"<<endl;

gotoxy(24,30);

cout<<" PLEASE RE-ENTER YOUR CHOICE : ";

cin>>choice1;

}

if (choice1 == 5)

{

copyright();

prog();

break;

}

else

{

clrscr();

border();

cal_menu();

gotoxy(24,28);

cout << " YOUR CHOICE : " << choice1;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 353/400

gotoxy(24,30);

cout << " ENTER FIRST NUMBER : " ;

cin >> num1;

gotoxy(24,32);

cout << " ENTER SECOND NUMBER : " ;

cin >> num2;

switch (choice1)

{

case 1: result= num1+num2; break;

case 2: result= num1-num2; break;

case 3: result= num1*num2; break;

case 4: result= num1/num2; break;

}

gotoxy(24,34);

cout << " ANSWER = " << result << endl;

gotoxy(24,36);

cout<<" PRESS ENTER TO CONTINUE";

getch();

}

} while (choice1<5 && choice1 >=1);

}

void number_details()

{

do

{

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 354/400

clrscr ();

border();

num_details();

gotoxy(24,28);

cout << " ENTER YOUR CHOICE : ";

cin>>choice1;

while(choice1>5 ||choice1<1)

{

clrscr();

border();

num_details();

gotoxy(24,24);

cout << " 4 " << " EXIT " << endl;

gotoxy(24,28);

cout<<" INVALID CHOICE !!!"<<endl;

gotoxy(24,30);

cout<<" PLEASE RE-ENTER YOUR CHOICE : ";

cin>>choice1;

}

if (choice1 == 5)

{

copyright();

prog();

break;

}

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 355/400

else

{

clrscr();

border();

num_details();

gotoxy(24,28);

cout << " YOUR CHOICE : " << choice1;

switch (choice1)

{

case 1:

gotoxy(24,30);

cout<<"ENTER A NUMBER : ";

cin >> num4;

gotoxy(24,32);

cout<<"THE FACTORS OF " << num4 << " ARE : " << endl

<<endl;

gfact=num4/2;

gotoxy(24,34);

for ( fact2=1; fact2<=gfact; fact2++)

{

if (num4%fact2==0)

cout<<fact2<<" ";

}

cout<<" and " << num4;

break;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 356/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 357/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 358/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 359/400

{

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

{

cout<<j<<" ";

}

cout<<"\n";

}

break;

case 2: //PYRAMID 2

for(i=1;i<=9;i++)

{

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

{

cout<<i<<" ";

}

cout<<"\n";

}break;

case 3: //PYRAMID 3

for(i=1;i<=9;i++)

{

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

{

cout<<"* ";

}

cout<<"\n";

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 360/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 361/400

{

for(j=4;j>=i;j--)

{

cout<<" ";

}

for(x=1;x<=i;x++)

{

cout<<x;

}

cout<<"\n";

}break;

case 7: //PYRAMID 7

for(i=1;i<=4;i++)

{

for(j=4;j>=i;j--)

{

cout<<" ";

}

for(x=i;x>=1;x--)

{

cout<<x;

}

cout<<"\n";

}break;

case 8: //PYRAMID 8

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 362/400

for( i=1;i<=4;i++)

{

for(j=4;j>=i;j--)

{

cout<<" ";

}

for( x=i;x>=1;x--)

{

if(x%2==0)

cout<<"*";

else

cout<<"@";

}

cout<<"\n";

}

break;

case 9: //PYRAMID 9

for(i=1;i<=4;i++)

{

for(j=4;j>=i;j--)

{

cout<<" ";

}

for( x=i;x>=1;x--)

{

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 363/400

if(x%2==0)

cout<<"* ";

else

cout<<"@ ";

}

cout<<"\n";

}break;

case 10: //PYRAMID 10

for( i=1;i<=4;i++)

{

for( j=4;j>=i;j--)

{

cout<<" ";

}

for(x=i;x>=1;x--)

{

if(i%2==0)

cout<<"*";

else

cout<<"@";

}

cout<<"\n";

}break;

case 11: //PYRAMID 11

int count,i;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 364/400

for(count=0;count<=5;count++)

{

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

cout<<'*';

cout<<endl;

}

for(count=4;count>=0;count--)

{

for(i=count;i>=0;i--)

cout<<'*';

cout<<endl;

}

break;

case 12: //PYRAMID 12

for( i=1;i<=4;i++)

{

for(j=4;j>=i;j--)

{

cout<<" ";

}

for( x=1;x<=i;x++)

{

cout<<x<<" ";

}

cout<<"\n";

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 365/400

}

for(i=3;i>=1;i--)

{

for(int j=i;j<=4;j++)

{

cout<<" ";

}

for(int x=1;x<=i;x++)

{

cout<<x<<" ";

}

cout<<"\n";

} break;

case 13:

copyright();

prog();

break;

}

getch();

}

void matrices(int fx)

{

clrscr();

long a[10][10],b[10][10],c[10][10],count1, count2,ra,ca,rb,cb,

rosm[10], colsm[10], row, col, asum=0,bsum=0;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 366/400

char choice;

switch(fx)

{

case 1: //ADDITION OF TWO MATRICES

do

{

clrscr();

cout<<"\nINPUT ROW FOR MATRIX A: ";

cin>>ra;

cout<<"\nINPUT COLUMN FOR MATRIX A: ";

cin>>ca;

cout<<"\nINPUT ROW FOR MATRIX B: ";

cin>>rb;

cout<<"\nINPUT COLUMN FOR MATRIX B: ";

cin>>cb;

if((ra==rb)&&(ca==cb))

cout<<"\nTHE TWO MATRICES CAN BE ADDED AS THEY ARE

IDENTICAL.";

else

{

cout<<"\nTHE TWO MATRICES CANNOT BE ADDED SINCE THEY

ARE NOT INDENTICAL.";

cout<<"\nTHANK YOU.";

getch();

copyright();

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 367/400

matmenu();

}

cout<<"\n\nINPUT ELEMENTS FOR MATRIX A :\n";

for(count1=0;count1<ra;count1++)

{

cout<<"\n";

for(count2=0;count2<ca;count2++)

cin>>a[count1][count2];

}

cout<<"\n\nINPUT ELEMENTS FOR MATRIX B :\n";

for(count1=0;count1<rb;count1++)

{

cout<<"\n";

for(count2=0;count2<cb;count2++)

cin>>b[count1][count2];

}

for(count1=0;count1<ra;count1++)

{

for(count2=0;count2<ca;count2++)

c[count1][count2]=a[count1][count2]+b[count1][count2];

}

clrscr();

cout<<"MATRIX A: ";

for(count1=0;count1<ra;count1++)

{

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 368/400

cout<<"\n\n";

for(count2=0;count2<ca;count2++)

cout<<"\t"<<a[count1][count2];

}

cout<<"\n\nMATRIX B: ";

for(count1=0;count1<rb;count1++)

{

cout<<"\n\n";

for(count2=0;count2<cb;count2++)

cout<<"\t"<<b[count1][count2];

}

cout<<"\n\nMATRIX C (NEW TO REPRESENT THE SUM OF MATRICES

A & B): ";

for(count1=0;count1<ra;count1++)

{

cout<<"\n\n";

for(count2=0;count2<ca;count2++)

cout<<"\t"<<c[count1][count2];

}

cout<<"\n\nDO YOU WISH TO RE-EXECUTE THE PROGRAM?(Y/N) : ";

cin>>choice;

}while(choice=='y'||choice=='Y');

break;

case 2: // SUBTRACTION OF A MATRIX FROM ANOTHER

do

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 369/400

{

clrscr();

cout<<"\nINPUT ROW FOR MATRIX A: ";

cin>>ra;

cout<<"\nINPUT COLUMN FOR MATRIX A: ";

cin>>ca;

cout<<"\nINPUT ROW FOR MATRIX B: ";

cin>>rb;

cout<<"\nINPUT COLUMN FOR MATRIX B: ";

cin>>cb;

if((ra==rb)&&(ca==cb))

cout<<"\nSUBTRACTION BETWEEN THE TWO MATRICES

IS POSSIBLE.";

else

{

cout<<"\nSUBTRACTION BETWEEN THE TWO MATRICES

IS NOT POSSIBLE.";

cout<<"\nTHANK YOU.";

getch();

copyright();

matmenu();

}

cout<<"\n\nINPUT ELEMENTS FOR MATRIX A :";

for(count1=0;count1<ra;count1++)

{

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 370/400

cout<<"\n";

for(count2=0;count2<ca;count2++)

cin>>a[count1][count2];

}

cout<<"\n\nINPUT ELEMENTS FOR MATRIX B :";

for(count1=0;count1<rb;count1++)

{

cout<<"\n";

for(count2=0;count2<cb;count2++)

cin>>b[count1][count2];

}

for(count1=0;count1<ra;count1++)

{

for(count2=0;count2<ca;count2++)

c[count1][count2]=a[count1][count2]-b[count1]

[count2];

}

clrscr();

cout<<"MATRIX A: ";

for(count1=0;count1<ra;count1++)

{

cout<<"\n\n";

for(count2=0;count2<ca;count2++)

cout<<"\t"<<a[count1][count2];

}

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 371/400

cout<<"\n\nMATRIX B: ";

for(count1=0;count1<rb;count1++)

{

cout<<"\n\n";

for(count2=0;count2<cb;count2++)

cout<<"\t"<<b[count1][count2];

}

cout<<"\n\nMATRIX C (NEW TO REPRESENT THE DIFFERENCE

BETWEEN MATRICES A & B): ";

for(count1=0;count1<ra;count1++)

{

cout<<"\n\n";

for(count2=0;count2<ca;count2++)

cout<<"\t"<<c[count1][count2];

}

cout<<"\n\nDO YOU WISH TO RE-EXECUTE THE PROGRAM?(Y/N):

";

cin>>choice;

}while(choice=='Y'||choice=='y');

break;

case 3: // MULTIPLICATION OF TWO MATRICES

do

{

clrscr();

cout<<"INPUT ROW FOR MATRIX A: ";

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 372/400

cin>>ra;

cout<<"\nINPUT COLUMN FOR MATRIX A: ";

cin>>ca;

cout<<"\nINPUT ROW FOR MATRIX B: ";

cin>>rb;

cout<<"\nINPUT COLUMN FOR MATRIX B: ";

cin>>cb;

if((ra==rb)&&(ca==cb))

cout<<"\nMULTIPLICATION OF THE TWO MATRICES IS

POSSIBLE.";

else

{

cout<<"\nMULTIPLICATION OF THE TWO MATRICES IS NOT

POSSIBLE.";

cout<<"\nTHANK YOU.";

getch();

copyright();

matmenu();

}

cout<<"\n\nINPUT ELEMENTS FOR MATRIX A :";

for(count1=0;count1<ra;count1++)

{

cout<<"\n";

for(count2=0;count2<ca;count2++)

cin>>a[count1][count2];

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 373/400

}

cout<<"\n\nINPUT ELEMENTS FOR MATRIX B :";

for(count1=0;count1<rb;count1++)

{

cout<<"\n";

for(count2=0;count2<cb;count2++)

cin>>b[count1][count2];

}

for(count1=0;count1<ra;count1++)

{

for(count2=0;count2<cb;count2++)

{

c[count1][count2]=0;

for(count3=0;count3<ca;count3++)

{

c[count1][count2]+=a[count1][count3]*b[count3][count2];

}

}

}

clrscr();

cout<<"MATRIX A: ";

for(count1=0;count1<ra;count1++)

{

cout<<"\n\n";

for(count2=0;count2<ca;count2++)

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 374/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 375/400

{

clrscr();

cout<<"ENTER THE NUMBER OF ROWS FOR MATRIX : ";

cin>>row;

cout<<"ENTER THE NUMBER OF COLUMN FOR MATRIX : ";

cin>>col;

cout<<"ENTER THE ELEMENTS FOR MATRIX :\n ";

for(count1=0;count1<row;count1++)

{

cout<<"\n";

for(count2=0; count2<col; count2++)

cin>>a[count1][count2];

}

for(count1=0; count1<row;count1++)

{

rosm[count1]=0;

for(count2=0;count2<col; count2++)

rosm[count1] += a[count1][count2];

}

for(count2=0; count2<col; count2++)

{

colsm[count2]=0;

for(count1=0;count1<row; count1++)

colsm[count2] += a[count1][count2];

}

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 376/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 377/400

cin>>col;

cout<<"\nENTER THE ELEMENTS FOR THE MATRIX :\n\n";

for(count1=0;count1<row;count1++)

{

for(count2=0; count2<col; count2++)

cin>>a[count1][count2];

}

asum=0;

for(count1=0; count1<row;count1++)

{

for(count2=0;count2<col; count2++)

{

if(count1<count2)

asum+=a[count1][count2];

}

}

bsum=0;

for(count1=0; count1<row;count1++)

{

for(count2=0;count2<col; count2++)

{

if(count1>count2)

bsum+=a[count1][count2];

}

}

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 378/400

for(count1=0;count1<row;count1++)

{

cout<<"\n\n";

for(count2=0; count2<col; count2++)

cout<<"\t"<< a[count1][count2];

}

cout<<"\n\nTHE ELEMENTS OF THE MAIN DIAGONAL ARE : ";

for(count1=0; count1<row;count1++)

{

for(count2=0;count2<col; count2++)

{

if(count1==count2)

cout<< a[count1][count2] << " ";

}

}

cout<<"\n\nTHE SUM OF THE ELEMENTS ABOVE THE MAIN

DIAGONAL : ";

cout<<asum;

cout<<"\n\nTHE SUM OF THE ELEMENTS BELOW THE MAIN

DIAGONAL : ";

cout<<bsum;

cout<<"\n\nDO YOU WISH TO RE-EXECUTE THE PROGRAM?

(Y/N) : ";

cin>>choice;

}while(choice=='y'||choice=='Y');

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 379/400

break;

case 6: //TRANSPOSE A MATRIX

do

{

clrscr();

cout<<"\nINPUT ROW FOR MATRIX A: ";

cin>>ra;

cout<<"\nINPUT COLUMN FOR MATRIX A: ";

cin>>ca;

cout<<"\nINPUT ELEMENTS FOR MATRIX A :";

for(count1=0;count1<ra;count1++)

{

cout<<"\n";

for(count2=0;count2<ca;count2++)

cin>>a[count1][count2];

}

for(count1=0;count1<ca;count1++)

{

for(count2=0;count2<ra;count2++)

b[count1][count2]=a[count2][count1];

}

clrscr();

cout<<"MATRIX A: ";

for(count1=0;count1<ra;count1++)

{

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 380/400

cout<<"\n\n";

for(count2=0;count2<ca;count2++)

cout<<"\t"<<a[count1][count2];

}

cout<<"\n\nMATRIX B (TRANSPOSED FORM OF MATRIX A): ";

for(count1=0;count1<ca;count1++)

{

cout<<"\n\n";

for(count2=0;count2<ra;count2++)

cout<<"\t"<<b[count1][count2];

}

cout<<"\n\nDO YOU WISH TO RE-EXECUTE THE PROGRAM?

(Y/N) : ";

cin>>choice;

}while(choice=='y'||choice=='Y');

}

copyright(); matmenu();

}

void cardgame()

{

do

{

clrscr();

cout<<"CARD SELECTION GAME"<<endl;

cout<<"\n\nWELCOME!"<<endl;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 381/400

cout << "\nYOU WILL BE HAPPY TO KNOW THAT NO USER CAN

DEFEAT ME IN THIS GAME." << endl<<endl;

cout << " \n\n\nRULES TO PLAY THE GAME: " << endl;

cout << " \n\nI HAVE A SET OF 25 CARDS.";

cout << " \nWE SHALL HAVE TO RANDOMLY SELECT 1 OR 2 OR 3

CARDS."<<endl;

cout << " \nSELECTION OF MORE THAN 3 CARDS IS NOT

ALLOWED."<<endl;

cout << " \nTHE LOSER WILL BE LEFT WITH ONLY ONE CARD IN

THE SET TO BE SELECTED BY HIM.";

cout << " \nI HOPE EVERYTHING IS CLEAR." << endl;

cout << " \nBEST OF LUCK!" << endl;

cout<<"\nIF YOU DISAGREE THEN PRESS 'y' TO

CONTINUE."<<endl;

cout<<"\nIF YOU ARE A BORN LOSER THEN PRESS ANY KEY TO

EXIT." << endl<<endl;

start=getche();

if (start=='y'||start=='Y')

{

cout << " \nPERHAPS YOUR BOLDNESS IS CHARACTERIZED."

<< endl;

cout << " \nPRESS ENTER TO CONTINUE"<<endl;

getch();

clrscr();

ncardleft=25;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 382/400

do

{

clrscr();

cout << " PLEASE SELECT THE CARDS.(1/2/3)"<< endl;

cin>>num1;

if (num1<4)

{

cout << " SO, YOU SELECT : " << num1 << "

CARDS." << endl;

num2=4-num1;

cout << " OK, I SELECT : " << num2 << "

CARDS." << endl;

ncardleft=ncardleft-4;

cout << " THE NUMBER OF CARDS LEFT IN

THE SET NOW IS : " << ncardleft << endl;

}

else

cout << " OOPS! SELECTION OF MORE THAN

3 CARDS IS NOT ALLOWED. " << endl;

getch();

}while (ncardleft>1);

cout << " NOW THERE IS ONLY ONE CARD LEFT FOR YOUR

SELECTION." << endl;

cout << " SO YOU HAVE LOST THE GAME."<<endl;

cout << " I M GLAD TO INFORM ABOUT YOUR GOOD

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 383/400

BRAINSTORMING CAPABILITY." << endl;

cout << " BUT AFTER ALL YOU CAN NEVER DEFEAT ME IN THIS

GAME."<<endl;

cout << " THANK YOU FOR PLAYING THE GAME."<<endl;

cout << " CAUTION: TIME WASTAGE BY REPEATED PLAYING IS

NOT ADVISABLE.";

cout << " BYE!! " << endl;

}

else

cout << "THANK YOU TO PROVE YOURSELF LOSER. TRY YOUR

LUCK BETTER NEXT TIME." << endl;

cout<<"\nPRESS Y TO CONTINUE ELSE PRESS N TO EXIT : ";

decision=getche();

}while(decision=='y'||decision=='Y');

copyright(); prog();

}

char numname[100];

void numerology()

{

// KNOW YOURSELF THROUGH NUMEROLOGY

b:

clrscr();

cout<<"PRESS ANY KEY TO CONTINUE ";

getch();

int x=7,y=3;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 384/400

box(1,1,79,49,'*');

gotoxy(x,y);y+=2;

cout<<"WELCOME!!";

gotoxy(x,y);y+=2;

cout << "PLEASE ENTER YOUR NAME : ";

gets(numname);

gotoxy(x,y);y+=2;

cout<< "ENTER BIRTH DATE : (ddmmyyyy) ";

cin>>bdate;

//***********************************************************************************

*****

birth_date(bdate);

//******************************************************

while(date<1||date>31||month<1||month>12)

{

goto b;

}

//**************************************************************

while(date>29 && month==2 && ((year%100!=0 && year%4==0) || year%400==0))

{

goto b;

}

while(date>28 && month==2 && year%100!=0 && year%4!=0 && year%400!=0)

{

goto b;

}

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 385/400

if ((year%100!=0 && year%4==0) || year%400==0)

 julian=366;

else

 julian=365;

switch(month)

{

case 1: julian -= 31;

case 2: julian -= 31;

case 3: if ( (year%100!=0 && year%4==0) || year%400==0)

 julian -= 29;

else

 julian -= 28;

case 4: julian -= 31;

case 5: julian -= 30;

case 6: julian -= 31;

case 7: julian -= 30;

case 8: julian -= 31;

case 9: julian -= 31;

case 10: julian -= 30;

case 11: julian -= 31;

case 12: julian -= 30;

}

 julian+=date;

fours=(year-1)/4;

hundreds=(year-1)/100;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 386/400

four_hundreds=(year-1)/400;

day=((year+julian+fours+four_hundreds-hundreds)%7);

clrscr();

box(1,1,79,49,'*');

x=7;

y=4;

gotoxy(x,y);y+=2;

cout<<"PERSONAL DETAILS OF " << numname << " : " <<endl;

gotoxy(x,y);y+=2;

cout<<"BIRTH DATE : "<<date << " ";

gdate=date;

switch(month)

{

case 1:cout<<"JANUARY"; break;

case 2:cout<<"FEBRUARY"; break;

case 3:cout<<"MARCH"; break;

case 4:cout<<"APRIL"; break;

case 5:cout<<"MAY"; break;

case 6:cout<<"JUNE"; break;

case 7:cout<<"JULY"; break;

case 8:cout<<"AUGUST"; break;

case 9:cout<<"SEPTEMBER"; break;

case 10:cout<<"OCTOBER"; break;

case 11:cout<<"NOVEMBER"; break;

case 12:cout<<"DECEMBER"; break;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 387/400

}

cout<<" "<< year <<endl;

gotoxy(x,y);y+=2;

cout<<"BIRTH DAY : ";

switch(day)

{

case 0:cout<<"SATURDAY"; break;

case 1:cout<<"SUNDAY"; break;

case 2:cout<<"MONDAY"; break;

case 3:cout<<"TUESDAY"; break;

case 4:cout<<"WEDNESDAY";break;

case 5:cout<<"THURSDAY"; break;

case 6:cout<<"FRIDAY"; break;

}

for (sum=0; bdate!=0; bdate=bdate/10)

{

digit2=bdate%10;

sum=sum+digit2;

}

for (basicn=0; date!=0; date=date/10)

{

digit3=date%10;

basicn=basicn+digit3;

}

int l,m;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 388/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 389/400

cout<<"CAPRICORN";

else if(gdate>19)

cout<<"AQUARIUS";

break;

case 2: if(gdate<=18)

cout<<"AQUARIUS";

else if(gdate>18)

cout<<"PISCES";

break;

case 3: if(gdate<=19)

cout<<"PISCES";

else if(gdate>19)

cout<<"ARIES";

break;

case 4: if(gdate<=18)

cout<<"ARIES";

else if(gdate>18)

cout<<"TAURUS";

break;

case 5: if(gdate<=19)

cout<<"TAURUS";

else if(gdate>19)

cout<<"GEMINI";

break;

case 6: if(gdate<=20)

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 390/400

cout<<"GEMINI";

else if(gdate>20)

cout<<"CANCER";

break;

case 7: if(gdate<=21)

cout<<"CANCER";

else if(gdate>21)

cout<<"LEO";

break;

case 8: if(gdate<=21)

cout<<"LEO";

else if(gdate>21)

cout<<"VIRGO";

break;

case 9: if(gdate<=21)

cout<<"VIRGO";

else if(gdate>21)

cout<<"LIBRA";

break;

case 10:if(gdate<=22)

cout<<"LIBRA";

else if(gdate>22)

cout<<"SCORPIO";

break;

case 11:if(gdate<=20)

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 391/400

cout<<"SCORPIO";

else if(gdate>20)

cout<<"SAGITTARIUS";

break;

case 12:if(gdate<=20)

cout<<"SAGITTARIUS";

else if(gdate>20)

cout<<"CAPRICORN";

break;

}

gotoxy(x,y);y+=2;

cout <<"BASIC NUMBER : "<< basicn << endl;

switch(basicn)

{

case 1:

gotoxy(x,y);y+=2;

cout<<"LUCKY COLOURS : PALEST YELLOW, PALEST GREEN, DEEP

ORANGE,";

gotoxy(x,y);y+=2;

cout<<"GOLDEN HUES, WHITE, CREAM.";

gotoxy(x,y);y+=2;

cout<<"LUCKY GEMS : TOPAZ, AMBER.";

break;

case 2:

gotoxy(x,y);y+=2;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 392/400

cout<<"LUCKY COLOURS :PALEST GREEN, CREAM, WHITE";

gotoxy(x,y);y+=2;

cout<<"PALEST YELLOW, GOLDEN HUES.";

gotoxy(x,y);y+=2;

cout<<"LUCKY GEMS : PEARL, CAT'S EYE, MOONSTONE.";

break;

case 3:

gotoxy(x,y);y+=2;

cout<<"LUCKY COLOURS : MAUVE, VIOLET, PURPLE";

gotoxy(x,y);y+=2;

cout<<"LUCKY GEMS : AMETHYST";

break;

case 4:

gotoxy(x,y);y+=2;

cout<<"LUCKY COLOURS : GREY, FAWN, ELECTRIC SHADES, ";

gotoxy(x,y);y+=2;

cout<<"TINTS OF YELLOW AND GREEN.";

gotoxy(x,y);y+=2;

cout<<"LUCKY GEMS : SAPPHIRE";

break;

case 5:

gotoxy(x,y);y+=2;

cout<<"LUCKY COLOURS : SILVER GREY, GLISTENING WHITE,

SILVER,";

gotoxy(x,y);y+=2;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 393/400

cout<<"GOLDEN AND ALL GLITTERING SHADES.";

gotoxy(x,y);y+=2;

cout<<"LUCKY GEMS : PLATINUM, SILVER, DIAMOND";

break;

case 6:

gotoxy(x,y);y+=2;

cout<<"LUCKY COLOURS : MAINLY BLUE AND ALL OTHERS EXCEPT";

gotoxy(x,y);y+=2;

cout<<"BLACK AND DARK PURPLE";

gotoxy(x,y);y+=2;

cout<<"LUCKY GEMS : TURQOUISE AND EMARALD";

break;

case 7:

gotoxy(x,y);y+=2;

cout<<"LUCKY COLOURS :MAINLY GREEN AND YELLOW, CREAM,

WHITE,";

gotoxy(x,y);y+=2;

cout<<"PALEST YELLOW, GOLDEN HUES.";

gotoxy(x,y);y+=2;

cout<<"LUCKY GEMS : CAT'S EYE, MOONSTONES";

break;

case 8:

gotoxy(x,y);y+=2;

cout<<"LUCKY COLOURS : DARKEST SHADES OF GREY, BLUE,

BROWN";

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 394/400

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 395/400

case'8':sum+=8;break;

case'9':sum+=9;break;

}

}

else if(isalpha(numname[count]))

{

switch(numname[count])

{

case 'A':

case 'a':

sum+=1;break;

case 'B':

case 'b':

sum+=2;break;

case 'C':

case 'c':

sum+=3;break;

case 'D':

case 'd':

sum+=4;break;

case 'E':

case 'e':

sum+=5;break;

case 'F':

case 'f':

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 396/400

sum+=8;break;

case 'G':

case 'g':

sum+=3;break;

case 'H':

case 'h':

sum+=5;break;

case 'I':

case 'i':

sum+=1;break;

case 'J':

case 'j':

sum+=1;break;

case 'K':

case 'k':

sum+=2;break;

case 'L':

case 'l':

sum+=3;break;

case 'M':

case 'm':

sum+=4;break;

case 'N':

case 'n':

sum+=5;break;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 397/400

case 'O':

case 'o':

sum+=7;break;

case 'P':

case 'p':

sum+=8;break;

case 'Q':

case 'q':

sum+=1;break;

case 'R':

case 'r':

sum+=2;break;

case 'S':

case 's':

sum+=3;break;

case 'T':

case 't':

sum+=4;break;

case 'U':

case 'u':

sum+=6;break;

case 'V':

case 'v':

sum+=6;break;

case 'W':

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 398/400

case 'w':

sum+=6;break;

case 'X':

case 'x':

sum+=5;break;

case 'Y':

case 'y':

sum+=1;break;

case 'Z':

case 'z':

sum+=7;break;

}

}

if(numname[count]==' ')

{

first=sum;

flag++;

sum=0;

}

}

second=sum;

while(first>9)

{

temp=first%10;

first=first/10;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 399/400

first+=temp;

}

while(second>9)

{

temp=second%10;

second=second/10;

second+=temp;

}

if(flag==0)

{

gotoxy(x,y);y+=2;

cout<<"THE NUMBER OF YOUR NAME SUMS UP TO "<<second;

if(second!=basicn)

{

gotoxy(x,y);y+=2;

cout<<"OOPS!! YOUR NAME NUMBER IS NOT EQUAL TO YOUR

BASIC NUMBER.";

gotoxy(x,y);y+=2;

cout<<"TO MAKE YOURSELF LUCKY, IT IS NECESSARY. ";

gotoxy(x,y);y+=2;

cout<<"SO I SUGGEST YOU TO CHANGE YOUR NAME .";

}

else

{

gotoxy(x,y);y+=2;

8/9/2019 Object Oriented Using C++ programing collection

http://slidepdf.com/reader/full/object-oriented-using-c-programing-collection 400/400

cout<<"CONGRATULATIONS!! YOUR NAME NUMBER IS EQUAL

TO YOUR BASIC NUMBER.";

gotoxy(x,y);y+=2;

cout<<"SO IT IS VERY LUCKY AND WILL ALWAYS FAVOUR

YOU.";

}

}

else

{

gotoxy(x,y);y+=2;

cout<<"THE NUMBER OF YOUR FIRST NAME SUMS UP TO "<<first;

gotoxy(x,y);y+=2;

cout<<"THE NUMBER OF YOUR SECOND NAME SUMS UP TO "<<second;

if(first!=basicn)

{

gotoxy(x,y);y+=2; 

Recommended