programming in c++ by manny verma

Post on 31-May-2015

144 Views

Category:

Documents

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Submitted To: - Jasbir Kaur Submitted By:- Maninder Verma

10+1 (j)

Govt. Sen. sec model school P.A.U Ludhiana

ACKNOWLEDGEMENT

On every step there is need of guidance, support and motivation. This encourages a person to give his best performance and helps in reaching his goals.

This project is prepared in partial fulfillment of the requirements for the 10+1 (J) and

here we wish to take this opportunity to express our sincere gratitude to all those who

directly or indirectly helped us in completing this project.

First of all, we would like to pay our especially thanks to Mrs.JASBIR KAUR who

had taught us Programming in c++ and helped us during this project development work

and for completion of this project.

We pay our sincere thanks to Mr.NIPUL JAIN (software engineer in M.N.C) for his

kind cooperation and providing us ample facilities.

At the end, we express our gratitude to parents and friends who have always been the source of encouragement and inspiration.

1: ADDITION:

SrNo.Contents

Page No.

1.Program for Addition

1

2.Program for switch statement

2-3

3. Program for GOTO statement 44. Program for IF IF statement 45. Program for while statement 56. Program for FOR loop 67. Program for FORFOR loop 7-88. Program for leep year 9-139. Program for swapping 1410. Program for Fibnoacce 15-2011. Program for Factorial 21-3212. Program for making table of any any number 3-3813. Program for virtual function 39-4014. Program for check eligibility for vote 41-4315. Program for HYBRID Inharitance 44-4716. Program for father&son multipal Inharitance 48-5017. Program for bank Inharitance 51-5618. Program for class train 57-6819. Program for simple inheritance with teacher 69-7120. Program for hospital Multipal Inharitance 72-74

#include<iostream.h>#include<conio.h>void main(){int a,b,c;clrscr();cout<<"Enter any two numbers";cin>>a>>b;c=a+b;cout<<"The addition is"<<c;getch();}

2: SWITCH statement:

#include<iostream.h>#include<conio.h>void main(){int n;clrscr();cout<<"************ created by Maninder vemra and co************\n";cout<<"enter you choice between 1 to 10\n";cout<<"enter your choice==>";cin>>n;switch(n){case 1:cout<<"sunday";break;case 2:cout<<"monday";break;case 3:cout<<"tuesday";break;case 4:cout<<"wednesday";break;case 5:cout<<"thrusday";break;case 6:cout<<"friday";

break;case 7:cout<<"saturday";break;default:cout<<"invalid number";}getch();}

3: GOTO statement:

# include<iostream.h># include<conio.h>void main(){int y;clrscr();a:cout<<"*********** Created by Maninder verma and company ***********\n\n\n\n";cout<<"*********** program for goto statement **********\n\n\n\n";cout<<"Enter any year to know it is leep year or not\n\n";cout<<"Enter your year here===>>\b";cin>>y;if (y%4==0){cout<<"your entered year is a leep year";}else{cout<<"this is not a leep year";}getch();goto a;}

4: IF-IF statement:

#include<iostream.h>#include<conio.h>void main(){int a,b;cout<<"koi do number add kar oe";cin>>a>>b;if (a>b){cout<<"pehla number vada ha";}If (a<b){cout<<”duja number vada ha”;}getch();}

5: WHILE statement:

# include<iostream.h># include<conio.h>void main(){int i=5;clrscr();cout<<"***********Created by maninder verma and company***********\n\n\n";while (i>=1){cout<<i<<endl;i--;}getch(); }

6: FOR loop:

# include<iostream.h># include<conio.h>void main(){int i;cout<<"************ Created by maninder verma and team***********\n\n\n";for (i=1; i<=5; i++){cout<<i<<endl;}getch();}

7: FOR FOR loop:

# include<iostream.h># include<conio.h>void main(){int i,j;clrscr();cout<<"************** created by maninder verma and team ***********\n\n";for (i=1; i<=5; i++){cout<<"\n\t";cout<<i<<endl;}for (j=5; j>=1; j--){cout<<" ";cout<<j<<endl;}getch();}

8: LEEP YEAR:

#include<iostream.h>#include<conio.h>void main(){int y;cout <<"koi ve year enter kar oe";cin>>y;if (y%4==0){cout<<"year is leep year";}else{cout<<"year is not a leep year";}getch();}

9: SWAPPING:

#include<iostream.h>#include<conio.h>void main(){int x,y,z;cout <<"koi do number enter kar oe";cin>>x>>y;z=x;x=y;y=z;cout<<x<<y;getch();}

10: FIBNOACEE:

# include<iostream.h>#include<conio.h>class father{private:int a;char n[10];public:void getdata(){cout<<"enter the name of father==>";cin>>a;cout<<"\n";cout<<"enter the age of father==>";cin>>n;cout<<"\n";}void putdata(){cout<<"name of father"<<n;cout<<"age of father"<<a;}};class son: public father{private:int p;char n[10];public:void getdata1(){

getdata();cout<<"enter phone of son==>";cin>>p;cout<<"enter name of son==>";cin>>n;}void putdata1(){putdata();cout<<"the phone"<<p;cout<<"name is"<<n;}};void main(){son s;clrscr();s.putdata1();s.getdata1();getch();}

11: FACTORIAL:

# include<iostream.h>#include<conio.h>void main(){int n,i,ans=1;clrscr();a:cout<<"******* created by and maninder ********\n\n\n";cout<<"enter any number==>";cin>>n;for (i=1; i<=n; i++){ans=ans*i;}cout<<ans;goto a;getch();}

12: TO MAKE TABEL OF ANY NUMBER:

# include<iostream.h># include<conio.h>void main(){long int n,i;clrscr();cout<<"************ created by Maninder verma and team ************\n\n\n";cout<<"Enter any number==>";cin>>n;for (i=1; i<=10; i++){cout<<n*i<<endl;}getch();}

13: VIRTUAL FUNCTION:

#include<iostream.h>#include<conio.h>class father{private:int a;public:void getdata(){cout<<"enter age of father";cin>>a;}void putdata(){cout<<"the age of father is"<<a;}};class son:public father{private:int a;public:virtual void getdata(){cout<<"enter the age of son";cin>>a;}virtual void putdata(){cout<<"the age of son is"<<a;}

};void main(){father f;father*p;p=&f;p->getdata();p->putdata();son s;son*p1;p1=&s;p1->getdata();p1->putdata();getch();}

15: HYBRID INHARITANCE:

# include<iostream.h># include<conio.h>class grandfather{private:int a;char n[10];public:void getdata(){cout<<"Enter the age of grandfather==>";cin>>a;cout<<"\n";cout<<"Enter the name of grandfather==>";cin>>n;cout<<"\n";}void putdata(){cout<<"age of G.F"<<a;cout<<"\n";cout<<"name of G.F"<<n;}};class father:public grandfather{private:char a[10];public:void getdata1(){

getdata();cout<<"Enter the name of father";cin>>a;}void putdata1(){putdata();cout<<"the name of father is"<<a;}};class mother:public grandfather{private:int p;public:void getdata2(){getdata();cout<<"Enter the phone no of mother";cin>>p;}void putdata2(){putdata();cout<<"the phone no of mother is"<<p;}};class son:public father,mother{private:char m[10];

public:void getdata3(){getdata1();getdata2();cout<<"Enter the marks of son";cin>>m;cout<<"\n";}void putdata3(){putdata1();putdata2();cout<<"The marks of son is"<<m;}};void main(){son s;clrscr();s.getdata3();s.putdata3();getch();}

15: MULTIPAL INHARITANCE:

# include<iostream.h>#include<conio.h>class father{private:int a;char n[10];public:void getdata(){cout<<"enter the name of father==>";cin>>a;cout<<"\n";cout<<"enter the age of father==>";cin>>n;cout<<"\n";}void putdata(){cout<<"name of father"<<n;cout<<"age of father"<<a;}};class son: public father{private:int p;char n[10];public:void getdata1(){

getdata();cout<<"enter phone of son==>";cin>>p;cout<<"enter name of son==>";cin>>n;}void putdata1(){putdata();cout<<"the phone"<<p;cout<<"name is"<<n;}};void main(){son s;clrscr();s.putdata1();s.getdata1();getch();}

16: BANK:

# include<iostream.h># include<conio.h>class bank{private:char n;public:void getdata(){cout<<"enter the name of bank";cin>>n;cout<<"\n";}void putdata(){cout<<"enter the name of bank";cin>>n;cout<<"\n";}};class manager{private:char n[20];int a;public:void getdata1(){

cout<<"enter the name";cin>>n;cout<<"\n";cout<<"enter the age";cin>>a;cout<<"\n";}void putdata1(){cout<<"enter the name and age"<<n<<a;}};class coustmer: public bank,manager{private:int p;public:void getdata2(){getdata();getdata1();cout<<"enter the phone";cin>>p;}void putdata2(){putdata();putdata1();cout<<"the phone is"<<p;}};

void main(){coustmer c;clrscr();c.getdata2();c.putdata2();getch();}

18: CLASS TRAIN:

#include<iostream.h>#include<conio.h>class train{private:int b;int tn;char s[20];char d[20];float l;public:train(){tn=479;s="dehli";d="chd";l=52.95;b=70;}void putdata(){cout<<"the train no,source,destination and load copeste"<<tn<<s<<d<<l;}};void main(){train.t;t.putdata();getch();}

19: SIMPLE IHARITANCE (WITH TEACHER EXAMPLE)

# include<iostream.h># include<conio.h>class teacher{private:int a;char n[10];float i;public:void manny(){cout<<"Enter the name of teacher==>";cin>>n;cout<<"Enter the age of teacher==>";cin>>a;cout<<"Enter the income of teacher==>";cin>>i;}void verma(){cout<<"Name of teacher is==>"<<n<<endl;cout<<"\n";cout<<"Age of teacher is==>"<<a<<endl;cout<<"\n";cout<<"Income of teacher is==>"<<i<<endl;}};

void main(){clrscr();teacher t;t.manny();t.verma();getch();}

20: HOSPITAL INHARITANCE:

#include<iostream.h>#include<conio.h>class hospital{private:char n[10];int h;public:void getdata(){cout<<"Enter the name of hospital==>";cin>>n;cout<<"\n";cout<<"Enter the height==>";cin>>h;}void putdata(){cout<<"\n\n\n";cout<<"Name of hospital==>"<<n;cout<<"\n\n";cout<<"Height of hospital==>"<<h;}};class doctor: public hospital{private:int a;char n[10];

public:void getdata1(){getdata();cout<<"\n\n\n\n";cout<<"enter the age of doctor==>";cin>>a;cout<<"\n\n";cout<<"enter the name of doctor==>";cin>>n;cout<<"\n\n";}void putdata1(){putdata();cout<<"age of doctor==>"<<a;cout<<"name of doctor==>"<<n;}};void main(){doctor s;s.getdata1();s.putdata1();getch();}

Our project on punjab electricity bill calculater :

# include<iostream.h># include<conio.h>void main(){int a;long float cr,pr,u;long float u0=2.40,u1=4.357,u2=3.91;clrscr();cout<<"\n\n\n\n";cout<<"\t\t****** CREATED BY GROUP A OF P.A.U STUDENT *****\n\n\n";cout<<"\n\n";cout<<"\t\tSOFTWARE TO CALCULATE YOU ELECTRICITY BILL\n\n\n";cout<<"\n\n\n";cout<<"\tEnter your current reading from your bill==> ";cin>>cr;cout<<"\n\n\n\n";cout<<"\t\t Enter you previous reading==> ";cin>>pr;cout<<"\n\n\n\n";u=cr-pr;cout<<"\t\t your used units==> "<<u<<endl;cout<<"\n\n\n\n";if (u<=100){a=u*u0;}if ((u>100)&&(u<=200))

{a=u*u2;}else{a=u*u1;}cout<<" -----------\n\n";cout<<"\t\t your current bill amount is==> "<<a;cout<<" -----------";

getch();}

********************** ****************** *************** ************

top related