# Class 12 20 Progs

• View
213

0

Embed Size (px)

Transcript

• 8/10/2019 Class 12 20 Progs

1/41

Submitted By:-

Sanuj Kumar

XII-D

C++ PROJECT

20

• 8/10/2019 Class 12 20 Progs

2/41

Program 01:-

Calculates area o circle !

rectangle and triangle using

#include#include

#include#define pi 3.14class fn{ public: void area(int); circle void area(int!int); rectan"le void area(float !int!int); trian"le;

void fn::area(int a){ cout

• 8/10/2019 Class 12 20 Progs

3/41

int a!b!r; clrscr(); fn ob; cout>a>>b; ob.area(a!b); brea; case 3: cout

• 8/10/2019 Class 12 20 Progs

4/41

Program 0\$:-%se o deault argument#

#include#include

int vol(int81!int8,!int83);

int main() { clrscr(); int len"th; int idth; int hei"ht; int volume; cout

• 8/10/2019 Class 12 20 Progs

5/41

return l'h';

Program 0&:-

Classes and objects - 01#

#include#include

class 5+&{int &ode;

char tem,6=;float rice;int ?t2;float @icount;void *ind@isc(){ if (?t2

• 8/10/2019 Class 12 20 Progs

6/41

cout

• 8/10/2019 Class 12 20 Progs

7/41

Program 0':-

(ssign! %)date (nd Dis)lay

inormation *Classes (nd

+bjects - 0\$,#

#include

#include#includeclass Aolers{char *DBame36=;char EDBame36=;int +versDboled!FaidenDovers!-unsD"iven!Gicets;

public:void initial(){cout

• 8/10/2019 Class 12 20 Progs

8/41

cout

• 8/10/2019 Class 12 20 Progs

9/41

Program 0:-

.eal /ie Cricet *Constructor(nd Destructor - 01,#

#include#include#include

class batsman{

public:char name,6=;int runDscore!indiDout;char modeout,6=;void "etdata(){cout

• 8/10/2019 Class 12 20 Progs

10/41

{cout

• 8/10/2019 Class 12 20 Progs

11/41

cout

• 8/10/2019 Class 12 20 Progs

12/41

clrscr();}

Program 0:-

2ra"el Plan 3 *Constructor (nd

Destructor - 0\$,#

class ravellan{lon" lan&ode;

char 'lace;int BumberDofDtravellers;int BumberDofDbuses;

public:ravellan(){lan&ode81661;strcp2(lace!\$%"ra\$);

BumberDofDtravellers87;BumberDofDbuses81;

void Belan(){ coutlan&ode;"ets(lace);cin>>BumberDofDtravellers;if(BumberDofDtravellers

• 8/10/2019 Class 12 20 Progs

13/41

cout

• 8/10/2019 Class 12 20 Progs

14/41

cin>>depo;displa2();

balance8balanceHdepo;cout

• 8/10/2019 Class 12 20 Progs

15/41

balance8balanceJith;cout

• 8/10/2019 Class 12 20 Progs

16/41

{ s."etdata();l1:cout

• 8/10/2019 Class 12 20 Progs

17/41

Program 06:-

7m)loyees (nd 8anagers

*In5eritance 3 0\$,#

#include#includeclass emplo2ee{

public:int num!house ;char cit2,6=! state,6=! name,6=!depart,6=;

public:void input(){coutname;coutnum;cout

• 8/10/2019 Class 12 20 Progs

18/41

{char name,6=;int n !i;

public:void "etdata(){cout>n;void info();;void mana"er::info()

{"etdata();for(i81;i

• 8/10/2019 Class 12 20 Progs

19/41

Program 09:-

%))er Case (nd /oer Case

*Data ;ile

• 8/10/2019 Class 12 20 Progs

20/41

filout1.close();filout,.close();filout3.close();"etch();

Program 10:-

8ulti)le insertion *Data ;ile

• 8/10/2019 Class 12 20 Progs

21/41

• 8/10/2019 Class 12 20 Progs

22/41

Program 11:-

Bubble Sort *(rrays -01,#

#include

#include

void main(){

clrscr();int i!a7=;void bub(int =);cout

• 8/10/2019 Class 12 20 Progs

23/41

• 8/10/2019 Class 12 20 Progs

24/41

cout

• 8/10/2019 Class 12 20 Progs

25/41

iHH;lenHH;'(str1Hlen) 8 I6I;

Program 1':-

Publication o boos or audio

cassettes *Pointers - 0\$,#

#include#include

• 8/10/2019 Class 12 20 Progs

26/41

;class Aoo : public ublication{

private:int pa"es; public:void "et@ata(){ublication::"etBame();cout

• 8/10/2019 Class 12 20 Progs

27/41

if(choice 88 IbI){ ptrubn= 8 ne Aoo; ptrubn=J>"et@ata(); else{ ptrubn= 8 ne ape; ptrubn=J>"et@ata(); nHH; coutchoice; hile(choice 88 I2I);for(int i86; iputBame();cout

• 8/10/2019 Class 12 20 Progs

28/41

public:?ueue( )

{front8rear8BKEE; void nsert( );void @elete( );void @ispla2( );;

void ?ueue::@elete( )

{

Bode 'emp;if(front8 8BKEE)cout

• 8/10/2019 Class 12 20 Progs

29/41

Program 1:-

In>? to Post>? Con"ersion using

stacs * /ined /ists! Stacs!

=ueues - 0\$,#

#include#include#include#include

• 8/10/2019 Class 12 20 Progs

30/41

strcp2(postfi0! );clrscr();cout

• 8/10/2019 Class 12 20 Progs

31/41

hile((popped 8 op())P 8 \#Y)

postfi0=8Y6Y;cout

• 8/10/2019 Class 12 20 Progs

32/41

leftbr 8 ri"htbr 8 6;

for( int i86;si=;iHH){ if (si= 8 8 \(Y) leftbrHH;else if ( si= 8 8Y)Y) ri"htbrHH;

if ( leftbr 8 8 ri"htbr) return 6;else if ( leftbr< ri"htbr ) return 1;else returnJ1;

Program 14:-

Se)erating 7"en (nd +dd

@umbers ;rom (rrayA(rrays 3

0#include#includevoid Uet1*rom,(int %EE=! int len){int '/9/B!'+@@!i;if(len],886){

/9/B8ne intlen=;+@@8ne intlen=;else{/9/B8ne int(len,)H1=;+@@8ne int(len,)=;

• 8/10/2019 Class 12 20 Progs

33/41

for(int 86;

• 8/10/2019 Class 12 20 Progs

34/41

Program 16:-

%))er Case (nd /oer Case

*(rrays - 0',#

#include #include

void main(){

clrscr();

char lineT6=;int numberDofDvoels!uc!lc!uv!lv;uc8lc8uv8lv86;cout

• 8/10/2019 Class 12 20 Progs

35/41

• 8/10/2019 Class 12 20 Progs

36/41

hile(Pfin.eof()){fin."etline(str!T6);if(str6=88I@I NN str6=88IFI){cout

• 8/10/2019 Class 12 20 Progs

37/41

cCueue() {

front8rear8J1; void insert(int ); int deletion(); void displa2();

;

void cCueue :: insert(int val) {

if((front886 ZZ rear88F%^J1) NN (rearH188front)) cout

• 8/10/2019 Class 12 20 Progs

38/41

else frontHH;

return ;

void cCueue :: displa2() {

int i; if(front88J1)

cout

• 8/10/2019 Class 12 20 Progs

39/41

,.@eletion3.@ispla24./0it\$;

coutch; sitch(ch) { case 1 : coutval;c1.insert(val);

brea; case , : val8c1.deletion();

cout

• 8/10/2019 Class 12 20 Progs

40/41

2

• 8/10/2019 Class 12 20 Progs

41/41