SlideShare a Scribd company logo
1 of 18
OBJECT ORIENTED PROGRAMMINGS 2010




Q 1) Define a class to represent a bank account. Include the following members:
Data Members:
   Name of the Depositor
   Account Number
   Type of Account
   Balance amount in the account

Member Functions:
   To assign the initial values.
   To deposit an account.
   To withdraw an amount after checking the balance.

Write a C++ main program to display account number, name and balance.




 1|Page
OBJECT ORIENTED PROGRAMMINGS 2010



#include<iostream.h>
#include<conio.h> //for clrscr()
#include<stdio.h> //for gets()
#include<iomanip.h>
const int LEN=30;
const int max=100;
class members
{ private:
 char name[LEN];
 unsigned long bal_amount;
 char acctype[LEN];
 public:
 unsigned long accnumb;
 members()
 { bal_amount =1000000;
 }
 void getdata()
 { cout<<"Enter Name:"<<endl;
   gets(name);
   cout<<"Enter AccountNo:"<<endl;
   cin>>accnumb;
   cout<<"Enter the Account-type:"<<endl;
   gets(acctype);
   cout<<"Enter the balance amount:"<<endl;
   cin>>bal_amount;
 }
 void putdata()
 { cout<<"Name: "<<name<<"t";
   cout<<"AccountNo: "<<accnumb<<"t";
   cout<<"Account Type: "<<acctype<<"t";
   cout<<"Balance Amount: "<<bal_amount<<"t";
   cout<<endl;
 }
 void withdraw()
 { unsigned long wdraw_amount;
   cout<<"Enter the amount U want to withdraw: t";
   cin>>wdraw_amount;
   cout<<endl;
   if(wdraw_amount>bal_amount || wdraw_amount%100!=0)
   { cout<<"U have entered the wrong amount."<<endl;
     cout<<"Amount less than balance and multiple of 100 only can be
withdrawn"<<endl;
     wdraw_amount=0;
   }
   else
2|Page
OBJECT ORIENTED PROGRAMMINGS 2010


  bal_amount= bal_amount-wdraw_amount;
  cout<<"Amount withdrawn: t"<<wdraw_amount<<"t";
  cout<<"Balance: t"<<bal_amount<<"t"<<endl;
  }
  void check_balance()
  {
    cout<<"Balance: t"<<bal_amount<<endl;
  }
  void deposit_amount()
  { unsigned long d_amount;
    cout<<"Enter the amount U want to deposit: t";
    cin>>d_amount;
    cout<<endl;
    bal_amount=bal_amount+d_amount;
    cout<<"Balance: t"<<bal_amount<<endl;
  }
};
void main()
{
 clrscr();
 members m[max];
 unsigned long acc_no;
 int n;
 cout<<"The no of records U want 2 be entered: t"<<endl;
 cin>>n;
 cout<<"Enter the following Records"<<endl;
 for (int i=0;i<n;++i)
 {
  cout<<"Record:t"<<i+1<<endl;
  m[i].getdata();
 }
 clrscr();
 for (i=0; i<n; ++i)
 {cout<<"Record "<<i+1<<endl;
  m[i].putdata();
 }
 char ch;
 cout<<"Do u want 2 continue for any account?"<<endl;
 cin>>ch;
 clrscr();
 while(ch=='y')
 {
  cout<<"Enter ur account not"<<endl;
  cin>>acc_no;
  for(i=0; i<n; i++)
  { if(acc_no==m[i].accnumb)
    { int opt;
3|Page
OBJECT ORIENTED PROGRAMMINGS 2010


     m[i].putdata();
     char ans;
     cout<<"Do U want 2 continue for any account-process(y/n)?t";
     cin>>ans;
     cout<<endl;
     while(ans=='y')
     {
        cout<<"Enter ur option (1-check balance, 2-deposit, 3-withdraw)"<<endl;
        cin>>opt;
        cout<<endl;
        switch(opt)
        { case 1: m[i].check_balance();
                   break;
           case 2: m[i].deposit_amount();
                   break;
           case 3: m[i].withdraw();
                   break;
           deafault: cout<<"Wrong Option"<<endl;
         }
         cout<<"Do U want 2 continue for next withdrawl/ deposit/ balance-inquiry?"<<endl;
         cin>>ans;
         cout<<endl;
        }
      }
     }
   cout<<"Do U want 2 continue for any other account?"<<endl;
   cin>>ch;
   }
   getch();
  }




OUTPUT
The no of records U want 2 be entered:
3
Enter the following Records
Record     1
Name:
Sarvesh
Enter Account No:
123456
Enter the Account-type:
Current
Enter the balance amount:
91234567

4|Page
OBJECT ORIENTED PROGRAMMINGS 2010


Record     2
Name:
Prashant
Enter Account No:
456789
Enter the Account-type:
Saving
Enter the balance amount:
90234567
Record     3
Name:
Rajeev
Enter Account No:
789012
Enter the Account-type:
Current
Enter the balance amount:
98765432

Clear-screen..............

Record    1
Name: Sarvesh       Account No: 123456         Account-type: Current      Balance amount: 91234567
Record    2
Name: Prashant        Account No: 456789       Account-type: Saving       Balance amount: 90234567
Record    3
Name: Rajeev          Account No: 789012       Account-type: Current      Balance amount: 98765432
Do u want 2 continue for any account?
y

Clear-screen...

Enter ur account no
789012
Name: Rajeev           Account No: 789012         Account-type: Current   Balance amount: 98765432
Do U want 2 continue for any account-process(y/n)? y
Enter ur option (1-check balance, 2-deposit, 3-withdraw)
1
Balance: 98765432
Do U want 2 continue for next withdrawl/ deposit/ balance-inquiry?
y
Enter ur option (1-check balance, 2-deposit, 3-withdraw)
2
Enter the amount U want to deposit: 67890543
Balance: 166655975
Do U want 2 continue for next withdrawl/ deposit/ balance-inquiry?
y
Enter ur option (1-check balance, 2-deposit, 3-withdraw)
3
Enter the amount U want to withdraw: 4567890
U have entered the wrong amount.
Amount less than balance and multiple of 100 only can be withdrawn
Amount withdrawn:           0        Balance: 166655975
Do U want 2 continue for next withdrawl/ deposit/ balance-inquiry?
y
Enter ur option (1-check balance, 2-deposit, 3-withdraw)
5|Page
OBJECT ORIENTED PROGRAMMINGS 2010


3
Enter the amount U want to withdraw: 4567800
Amount withdrawn:      4567800         Balance:        162088175
Do U want 2 continue for next withdrawl/ deposit/ balance-inquiry?
n
Do U want 2 continue for any other account?
n




        Q 2) Write an operator overloading program to write S3+=S2.




6|Page
OBJECT ORIENTED PROGRAMMINGS 2010




#include<iostream.h>
#include<conio.h>
class numb
{ private:
  int i;
  public:
  numb()
  { i=10;
  }
  void operator++()
  { i=i+1;
    cout<<i<<endl;
  }
};
void main()
{ numb n;
  clrscr();
  int j;
  cout<<"How many times u want to increment the value?t";
  cin>>j;
  for(int m=0;m<j;++m)
  {n.operator++();
  }
  getch();
}


OUTPUT
7|Page
OBJECT ORIENTED PROGRAMMINGS 2010


How many times u want to increment the value? 8
11
12
13
14
15
16
17
18




// overloading prefix ++ incrementer operator for obtaining Fibonacci series
#include<iostream.h>
#include<conio.h>
class fibonacci
{ private:
  unsigned long int f0, f1, fib;
  public:
  fibonacci(); //constructor
  void operator++();
  void display();
};
fibonacci::fibonacci()
{ f0=0;
  f1=1;
  fib=f0+f1;
}
void fibonacci::display()
{ cout<<fib<<"t";
}
void fibonacci::operator++()
{f0=f1;
 f1=fib;
 fib=f0+f1;
}

8|Page
OBJECT ORIENTED PROGRAMMINGS 2010


void main()
{
clrscr();
fibonacci obj;
int n;
cout<<"How many fibonacci numbers are to be displayed? n";
cin>>n;
for(int i=0; i<=n-1;++i)
{
obj.display();
++obj;
}
getch();
}


OUTPUT

How many fibonacci numbers are to be displayed?

10

1    2     3     5     8     13      21     34    55   89




Q 3) Write an operator overloading program to Overload ‘>’ operator so as to
find greater among two instances of the class.
9|Page
OBJECT ORIENTED PROGRAMMINGS 2010




//overloading of comparison operators
#include<iostream.h>
#include<conio.h>
class sample
{ private:
          int value;
  public:
          sample();
          sample( int one);
          void display();
          int operator > (sample obj);
};
sample::sample()
{
 value = 0;
 }
sample::sample( int one)
10 | P a g e
OBJECT ORIENTED PROGRAMMINGS 2010


{
 value = one;
}
void sample::display()
{
 cout<<"value "<<value<<endl;
}
int sample::operator > (sample obja)
{
 return (value > obja.value);
}
void main()
{
 clrscr();
 sample obja(20);
 sample objb(100);
 cout<<(obja>objb)<<endl;
 cout<<(objb>obja)<<endl;
 getch();
}


OUTPUT

0

1




11 | P a g e
OBJECT ORIENTED PROGRAMMINGS 2010




                  Q 4) WAP using Single and Multiple Inheritance.




//single inheritance using array of objects
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<iomanip.h>
const int max=100;
class basic_info
{
 private: char name[30];
          long int rollno;
          char sex;
 public: void getdata();
          void display();
}; //end of class declaration
class physical_fit:public basic_info
{
 private: float height,weight;
 public: void getdata();
         void display();
};
void basic_info::getdata()
12 | P a g e
OBJECT ORIENTED PROGRAMMINGS 2010


{
 cout<<"ENTER A NAME ? n";
 cin>>name;
 cout<<"ROLL No. ? n";
 cin>>rollno;
 cout<<"SEX ? n";
 cin>>sex;
}
void basic_info::display()
{
 cout<<name<<"        ";
 cout<<rollno<<"       ";
 cout<<sex<<"      ";
}
void physical_fit::getdata()
{
 basic_info::getdata();
 cout<<"HEIGHT ? n";
 cin>>height;
 cout<<"WEIGHT ? n";
 cin>>weight;
}
void physical_fit::display()
{
 basic_info::display();
 cout<<setprecision(2);
 cout<<height<<" ";
 cout<<weight<<"        ";
}
void main()
{
 clrscr();
 physical_fit a[max];
 int i,n;
 cout<<"HOW MANY STUDENTS ? n";
 cin>>n;
 cout<<"ENTER THE FOLLOWING INFORMATION n";
 for(i=0;i<=n-1;++i)
 {
  cout<<"RECORD : "<<i+1<<endl;
  a[i].getdata();
 }
 cout<<endl;
 cout<<"_________________________________________________ n";
 cout<<"NAME ROLLNO SEX HEIGHT WEIGHT n";
 cout<<"_________________________________________________ n";
 for(i=0;i<=n-1;++i)
13 | P a g e
OBJECT ORIENTED PROGRAMMINGS 2010


 {
  a[i].display();
  cout<<endl;
 }
 cout<<endl;
 cout<<"_________________________________________________ n";
 getch();
}




OUTPUT

HOW MANY STUDENTS?
3
ENTER THE FOLLOWING INFORMATION
RECORD: 1
ENTER A NAME?
Sarvesh
ROLL No. ?
13
 SEX?
M
 HEIGHT?
174
WEIGHT?
59
RECORD : 2
ENTER A NAME?
Prashant
ROLL No. ?
19
 SEX ?
M
 HEIGHT?
166
WEIGHT?
63
RECORD : 3
ENTER A NAME ?
Rajeev
ROLL No. ?
23
 SEX ?
M
 HEIGHT?
14 | P a g e
OBJECT ORIENTED PROGRAMMINGS 2010


164
WEIGHT?
53

_________________________________________________
 NAME         ROLLNO SEX HEIGHT WEIGHT
 _________________________________________________

Sarvesh        13        M       174       59

Prashant       19        M       166       63

Rajeev          23       M       164       53

_________________________________________________




#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
class baseA
{
 public: int a;
};
class baseB
{
 public: int a;
};

15 | P a g e
OBJECT ORIENTED PROGRAMMINGS 2010


class baseC
{
 public: int a;
};
class derivedD: public baseA,public baseB, public baseC
{
 public: int a;
};
void main()
{
 clrscr();
 derivedD objd;
 objd.a=10; //local to the derived class
 cout<<"n VALUE OF a IN THE DERIVED CLASS = "<<objd.a;
 cout<<endl;
 cout<<"n VALUE OF a IN THE baseA = "<<objd.baseA::a;
 cout<<endl;
 cout<<"n VALUE OF a IN THE baseB = "<<objd.baseB::a;
 cout<<endl;
 cout<<"n VALUE OF a IN THE baseC = "<<objd.baseC::a;
 cout<<endl;
 cout<<endl;
 getch();
}




#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
class baseA
{
 public: int a;
};
class baseB
16 | P a g e
OBJECT ORIENTED PROGRAMMINGS 2010


{
 public: int a;
};
class baseC
{
 public: int a;
};
class derivedD: public baseA,public baseB, public baseC
{
 public: int a;
};
void main()
{
 clrscr();
 derivedD objd;
 objd.a=10;
 objd.baseA::a=20;
 objd.baseB::a=30;
 objd.baseC::a=40;
 cout<<"n VALUE OF a IN THE DERIVED CLASS = "<<objd.a;
 cout<<endl;
 cout<<"n VALUE OF a IN THE baseA = "<<objd.baseA::a;
 cout<<endl;
 cout<<"n VALUE OF a IN THE baseB = "<<objd.baseB::a;
 cout<<endl;
 cout<<"n VALUE OF a IN THE baseC = "<<objd.baseC::a;
 cout<<endl;
 cout<<endl;
 getch();
}




OUTPUT


VALUE OF a IN THE DERIVED CLASS = 10
VALUE OF a IN THE baseA = 20
VALUE OF a IN THE baseB = 30

17 | P a g e
OBJECT ORIENTED PROGRAMMINGS 2010


VALUE OF a IN THE baseC = 40




18 | P a g e

More Related Content

What's hot

Computer science Investigatory Project Class 12 C++
Computer science Investigatory Project Class 12 C++Computer science Investigatory Project Class 12 C++
Computer science Investigatory Project Class 12 C++Rushil Aggarwal
 
Computer science project work
Computer science project workComputer science project work
Computer science project workrahulchamp2345
 
Oops practical file
Oops practical fileOops practical file
Oops practical fileAnkit Dixit
 
Understanding storage class using nm
Understanding storage class using nmUnderstanding storage class using nm
Understanding storage class using nmmohamed sikander
 
Computer Science class 12
Computer Science  class 12Computer Science  class 12
Computer Science class 12Abhishek Sinha
 
Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++Bharat Kalia
 
computer project code ''payroll'' (based on datafile handling)
computer project code ''payroll'' (based on datafile handling)computer project code ''payroll'' (based on datafile handling)
computer project code ''payroll'' (based on datafile handling)Nitish Yadav
 
Geometric and material nonlinearity analysis of 2 d truss with force and duct...
Geometric and material nonlinearity analysis of 2 d truss with force and duct...Geometric and material nonlinearity analysis of 2 d truss with force and duct...
Geometric and material nonlinearity analysis of 2 d truss with force and duct...Salar Delavar Qashqai
 
Travel management
Travel managementTravel management
Travel management1Parimal2
 
Student Data Base Using C/C++ Final Project
Student Data Base Using C/C++ Final ProjectStudent Data Base Using C/C++ Final Project
Student Data Base Using C/C++ Final ProjectHaqnawaz Ch
 
Geometric nonlinearity analysis of springs with rigid element displacement co...
Geometric nonlinearity analysis of springs with rigid element displacement co...Geometric nonlinearity analysis of springs with rigid element displacement co...
Geometric nonlinearity analysis of springs with rigid element displacement co...Salar Delavar Qashqai
 
Pads lab manual final
Pads lab manual finalPads lab manual final
Pads lab manual finalAhalyaR
 
Nonlinear analysis of braced frame with hinge by hinge method in c programming
Nonlinear analysis of braced frame with hinge by hinge method in c programmingNonlinear analysis of braced frame with hinge by hinge method in c programming
Nonlinear analysis of braced frame with hinge by hinge method in c programmingSalar Delavar Qashqai
 
Informatics Practice Practical for 12th class
Informatics Practice Practical for 12th classInformatics Practice Practical for 12th class
Informatics Practice Practical for 12th classphultoosks876
 

What's hot (20)

Computer science Investigatory Project Class 12 C++
Computer science Investigatory Project Class 12 C++Computer science Investigatory Project Class 12 C++
Computer science Investigatory Project Class 12 C++
 
Computer science project work
Computer science project workComputer science project work
Computer science project work
 
Oops practical file
Oops practical fileOops practical file
Oops practical file
 
Understanding storage class using nm
Understanding storage class using nmUnderstanding storage class using nm
Understanding storage class using nm
 
Computer Science class 12
Computer Science  class 12Computer Science  class 12
Computer Science class 12
 
Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++
 
Stl algorithm-Basic types
Stl algorithm-Basic typesStl algorithm-Basic types
Stl algorithm-Basic types
 
Ss
SsSs
Ss
 
C programs
C programsC programs
C programs
 
computer project code ''payroll'' (based on datafile handling)
computer project code ''payroll'' (based on datafile handling)computer project code ''payroll'' (based on datafile handling)
computer project code ''payroll'' (based on datafile handling)
 
Geometric and material nonlinearity analysis of 2 d truss with force and duct...
Geometric and material nonlinearity analysis of 2 d truss with force and duct...Geometric and material nonlinearity analysis of 2 d truss with force and duct...
Geometric and material nonlinearity analysis of 2 d truss with force and duct...
 
Travel management
Travel managementTravel management
Travel management
 
Function basics
Function basicsFunction basics
Function basics
 
Implementing string
Implementing stringImplementing string
Implementing string
 
Student Data Base Using C/C++ Final Project
Student Data Base Using C/C++ Final ProjectStudent Data Base Using C/C++ Final Project
Student Data Base Using C/C++ Final Project
 
Cquestions
Cquestions Cquestions
Cquestions
 
Geometric nonlinearity analysis of springs with rigid element displacement co...
Geometric nonlinearity analysis of springs with rigid element displacement co...Geometric nonlinearity analysis of springs with rigid element displacement co...
Geometric nonlinearity analysis of springs with rigid element displacement co...
 
Pads lab manual final
Pads lab manual finalPads lab manual final
Pads lab manual final
 
Nonlinear analysis of braced frame with hinge by hinge method in c programming
Nonlinear analysis of braced frame with hinge by hinge method in c programmingNonlinear analysis of braced frame with hinge by hinge method in c programming
Nonlinear analysis of braced frame with hinge by hinge method in c programming
 
Informatics Practice Practical for 12th class
Informatics Practice Practical for 12th classInformatics Practice Practical for 12th class
Informatics Practice Practical for 12th class
 

Viewers also liked

Inventory management
Inventory managementInventory management
Inventory managementRajeev Sharan
 
Order specification sheet
Order specification sheetOrder specification sheet
Order specification sheetRajeev Sharan
 
Graduation Project (SA 8000 & it's frame work for Indian Apparel Manufacturing)
Graduation Project (SA 8000 & it's frame work for Indian Apparel Manufacturing)Graduation Project (SA 8000 & it's frame work for Indian Apparel Manufacturing)
Graduation Project (SA 8000 & it's frame work for Indian Apparel Manufacturing)Rajeev Sharan
 
Human resource management
Human resource managementHuman resource management
Human resource managementRajeev Sharan
 
Customer relationship management
Customer relationship managementCustomer relationship management
Customer relationship managementRajeev Sharan
 
P 10 p-4ac756g50(gb )
P 10 p-4ac756g50(gb )P 10 p-4ac756g50(gb )
P 10 p-4ac756g50(gb )Rajeev Sharan
 
RECENT TRENDS OF MAINTENANCE MANAGEMENT
RECENT TRENDS OF MAINTENANCE MANAGEMENTRECENT TRENDS OF MAINTENANCE MANAGEMENT
RECENT TRENDS OF MAINTENANCE MANAGEMENTRajeev Sharan
 
Production and materials management
Production and materials managementProduction and materials management
Production and materials managementRajeev Sharan
 
Material requirement planning
Material requirement planningMaterial requirement planning
Material requirement planningRajeev Sharan
 
SETTING UP OF A GARMENT INDUSTRY
SETTING UP OF A GARMENT INDUSTRYSETTING UP OF A GARMENT INDUSTRY
SETTING UP OF A GARMENT INDUSTRYRajeev Sharan
 
Maintenance management
Maintenance managementMaintenance management
Maintenance managementRajeev Sharan
 
Garment inspection report_dn1_page_2
Garment inspection report_dn1_page_2Garment inspection report_dn1_page_2
Garment inspection report_dn1_page_2Rajeev Sharan
 

Viewers also liked (20)

IPR
IPRIPR
IPR
 
Inventory management
Inventory managementInventory management
Inventory management
 
Order specification sheet
Order specification sheetOrder specification sheet
Order specification sheet
 
Graduation Project (SA 8000 & it's frame work for Indian Apparel Manufacturing)
Graduation Project (SA 8000 & it's frame work for Indian Apparel Manufacturing)Graduation Project (SA 8000 & it's frame work for Indian Apparel Manufacturing)
Graduation Project (SA 8000 & it's frame work for Indian Apparel Manufacturing)
 
Human resource management
Human resource managementHuman resource management
Human resource management
 
Customer relationship management
Customer relationship managementCustomer relationship management
Customer relationship management
 
Calculator code
Calculator codeCalculator code
Calculator code
 
P 10 p-4ac756g50(gb )
P 10 p-4ac756g50(gb )P 10 p-4ac756g50(gb )
P 10 p-4ac756g50(gb )
 
RECENT TRENDS OF MAINTENANCE MANAGEMENT
RECENT TRENDS OF MAINTENANCE MANAGEMENTRECENT TRENDS OF MAINTENANCE MANAGEMENT
RECENT TRENDS OF MAINTENANCE MANAGEMENT
 
Production and materials management
Production and materials managementProduction and materials management
Production and materials management
 
Final pl doc
Final pl docFinal pl doc
Final pl doc
 
Ergonomics
Ergonomics Ergonomics
Ergonomics
 
Material requirement planning
Material requirement planningMaterial requirement planning
Material requirement planning
 
SETTING UP OF A GARMENT INDUSTRY
SETTING UP OF A GARMENT INDUSTRYSETTING UP OF A GARMENT INDUSTRY
SETTING UP OF A GARMENT INDUSTRY
 
Shirt spec sheet
Shirt spec sheetShirt spec sheet
Shirt spec sheet
 
Maintenance management
Maintenance managementMaintenance management
Maintenance management
 
PAD FINAL DOC
PAD FINAL DOCPAD FINAL DOC
PAD FINAL DOC
 
Sp 02
Sp 02Sp 02
Sp 02
 
Sp 02
Sp 02Sp 02
Sp 02
 
Garment inspection report_dn1_page_2
Garment inspection report_dn1_page_2Garment inspection report_dn1_page_2
Garment inspection report_dn1_page_2
 

Similar to Rajeev oops 2nd march

This what Im suppose to do and this is what I have so far.In thi.pdf
This what Im suppose to do and this is what I have so far.In thi.pdfThis what Im suppose to do and this is what I have so far.In thi.pdf
This what Im suppose to do and this is what I have so far.In thi.pdfkavithaarp
 
Computer mai ns project
Computer mai ns projectComputer mai ns project
Computer mai ns projectAayush Mittal
 
Computer mai ns project
Computer mai ns projectComputer mai ns project
Computer mai ns projectAayush Mittal
 
C++ coding for Banking System program
C++ coding for Banking System programC++ coding for Banking System program
C++ coding for Banking System programHarsh Solanki
 
I need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdfI need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdfpnaran46
 
Cbsecomputersciencecclass12boardproject bankmanagmentsystem-180703065625-conv...
Cbsecomputersciencecclass12boardproject bankmanagmentsystem-180703065625-conv...Cbsecomputersciencecclass12boardproject bankmanagmentsystem-180703065625-conv...
Cbsecomputersciencecclass12boardproject bankmanagmentsystem-180703065625-conv...sriram sarwan
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical fileMitul Patel
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical FileAshwin Francis
 
C++ project
C++ projectC++ project
C++ projectSonu S S
 
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdf
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdfC++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdf
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdfJUSTSTYLISH3B2MOHALI
 
#include iostream #include BankAccountClass.cpp #include .pdf
#include iostream #include BankAccountClass.cpp #include .pdf#include iostream #include BankAccountClass.cpp #include .pdf
#include iostream #include BankAccountClass.cpp #include .pdfANJANEYAINTERIOURGAL
 
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyC++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyGrejoJoby1
 
Cbse computer science (c++) class 12 board project bank managment system
Cbse computer science (c++)  class 12 board project  bank managment systemCbse computer science (c++)  class 12 board project  bank managment system
Cbse computer science (c++) class 12 board project bank managment systempranoy_seenu
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101premrings
 
Dependency injection - the right way
Dependency injection - the right wayDependency injection - the right way
Dependency injection - the right wayThibaud Desodt
 

Similar to Rajeev oops 2nd march (20)

This what Im suppose to do and this is what I have so far.In thi.pdf
This what Im suppose to do and this is what I have so far.In thi.pdfThis what Im suppose to do and this is what I have so far.In thi.pdf
This what Im suppose to do and this is what I have so far.In thi.pdf
 
Computer mai ns project
Computer mai ns projectComputer mai ns project
Computer mai ns project
 
Computer mai ns project
Computer mai ns projectComputer mai ns project
Computer mai ns project
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
Statement
StatementStatement
Statement
 
project
projectproject
project
 
C++ coding for Banking System program
C++ coding for Banking System programC++ coding for Banking System program
C++ coding for Banking System program
 
I need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdfI need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdf
 
Cbsecomputersciencecclass12boardproject bankmanagmentsystem-180703065625-conv...
Cbsecomputersciencecclass12boardproject bankmanagmentsystem-180703065625-conv...Cbsecomputersciencecclass12boardproject bankmanagmentsystem-180703065625-conv...
Cbsecomputersciencecclass12boardproject bankmanagmentsystem-180703065625-conv...
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical file
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical File
 
C++ project
C++ projectC++ project
C++ project
 
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdf
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdfC++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdf
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdf
 
#include iostream #include BankAccountClass.cpp #include .pdf
#include iostream #include BankAccountClass.cpp #include .pdf#include iostream #include BankAccountClass.cpp #include .pdf
#include iostream #include BankAccountClass.cpp #include .pdf
 
Ch 4
Ch 4Ch 4
Ch 4
 
C++ TUTORIAL 1
C++ TUTORIAL 1C++ TUTORIAL 1
C++ TUTORIAL 1
 
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyC++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
 
Cbse computer science (c++) class 12 board project bank managment system
Cbse computer science (c++)  class 12 board project  bank managment systemCbse computer science (c++)  class 12 board project  bank managment system
Cbse computer science (c++) class 12 board project bank managment system
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
 
Dependency injection - the right way
Dependency injection - the right wayDependency injection - the right way
Dependency injection - the right way
 

More from Rajeev Sharan

More from Rajeev Sharan (20)

Supply chain management
Supply chain managementSupply chain management
Supply chain management
 
Production module-ERP
Production module-ERPProduction module-ERP
Production module-ERP
 
Supply chain management
Supply chain managementSupply chain management
Supply chain management
 
E smartx.ppt
E smartx.pptE smartx.ppt
E smartx.ppt
 
Maintenance management
Maintenance managementMaintenance management
Maintenance management
 
Maintenance management
Maintenance managementMaintenance management
Maintenance management
 
product analysis & development- sourcing
product analysis & development- sourcingproduct analysis & development- sourcing
product analysis & development- sourcing
 
Product Analysis & Development
Product Analysis & DevelopmentProduct Analysis & Development
Product Analysis & Development
 
Ergonomics
ErgonomicsErgonomics
Ergonomics
 
Total service management
Total service managementTotal service management
Total service management
 
Lean- automobile
Lean- automobileLean- automobile
Lean- automobile
 
Vb (2)
Vb (2)Vb (2)
Vb (2)
 
Vb (1)
Vb (1)Vb (1)
Vb (1)
 
Vb
VbVb
Vb
 
INVENTORY OPTIMIZATION
INVENTORY OPTIMIZATIONINVENTORY OPTIMIZATION
INVENTORY OPTIMIZATION
 
Professional practices
Professional practicesProfessional practices
Professional practices
 
Report writing.....
Report writing.....Report writing.....
Report writing.....
 
Business ethics @ tata
Business ethics @ tataBusiness ethics @ tata
Business ethics @ tata
 
Software maintenance
Software maintenance Software maintenance
Software maintenance
 
Software quality assurance
Software quality assuranceSoftware quality assurance
Software quality assurance
 

Recently uploaded

Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptx
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptxMusic 9 - 4th quarter - Vocal Music of the Romantic Period.pptx
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptxleah joy valeriano
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptshraddhaparab530
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 

Recently uploaded (20)

Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptx
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptxMusic 9 - 4th quarter - Vocal Music of the Romantic Period.pptx
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptx
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.ppt
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 

Rajeev oops 2nd march

  • 1. OBJECT ORIENTED PROGRAMMINGS 2010 Q 1) Define a class to represent a bank account. Include the following members: Data Members:  Name of the Depositor  Account Number  Type of Account  Balance amount in the account Member Functions:  To assign the initial values.  To deposit an account.  To withdraw an amount after checking the balance. Write a C++ main program to display account number, name and balance. 1|Page
  • 2. OBJECT ORIENTED PROGRAMMINGS 2010 #include<iostream.h> #include<conio.h> //for clrscr() #include<stdio.h> //for gets() #include<iomanip.h> const int LEN=30; const int max=100; class members { private: char name[LEN]; unsigned long bal_amount; char acctype[LEN]; public: unsigned long accnumb; members() { bal_amount =1000000; } void getdata() { cout<<"Enter Name:"<<endl; gets(name); cout<<"Enter AccountNo:"<<endl; cin>>accnumb; cout<<"Enter the Account-type:"<<endl; gets(acctype); cout<<"Enter the balance amount:"<<endl; cin>>bal_amount; } void putdata() { cout<<"Name: "<<name<<"t"; cout<<"AccountNo: "<<accnumb<<"t"; cout<<"Account Type: "<<acctype<<"t"; cout<<"Balance Amount: "<<bal_amount<<"t"; cout<<endl; } void withdraw() { unsigned long wdraw_amount; cout<<"Enter the amount U want to withdraw: t"; cin>>wdraw_amount; cout<<endl; if(wdraw_amount>bal_amount || wdraw_amount%100!=0) { cout<<"U have entered the wrong amount."<<endl; cout<<"Amount less than balance and multiple of 100 only can be withdrawn"<<endl; wdraw_amount=0; } else 2|Page
  • 3. OBJECT ORIENTED PROGRAMMINGS 2010 bal_amount= bal_amount-wdraw_amount; cout<<"Amount withdrawn: t"<<wdraw_amount<<"t"; cout<<"Balance: t"<<bal_amount<<"t"<<endl; } void check_balance() { cout<<"Balance: t"<<bal_amount<<endl; } void deposit_amount() { unsigned long d_amount; cout<<"Enter the amount U want to deposit: t"; cin>>d_amount; cout<<endl; bal_amount=bal_amount+d_amount; cout<<"Balance: t"<<bal_amount<<endl; } }; void main() { clrscr(); members m[max]; unsigned long acc_no; int n; cout<<"The no of records U want 2 be entered: t"<<endl; cin>>n; cout<<"Enter the following Records"<<endl; for (int i=0;i<n;++i) { cout<<"Record:t"<<i+1<<endl; m[i].getdata(); } clrscr(); for (i=0; i<n; ++i) {cout<<"Record "<<i+1<<endl; m[i].putdata(); } char ch; cout<<"Do u want 2 continue for any account?"<<endl; cin>>ch; clrscr(); while(ch=='y') { cout<<"Enter ur account not"<<endl; cin>>acc_no; for(i=0; i<n; i++) { if(acc_no==m[i].accnumb) { int opt; 3|Page
  • 4. OBJECT ORIENTED PROGRAMMINGS 2010 m[i].putdata(); char ans; cout<<"Do U want 2 continue for any account-process(y/n)?t"; cin>>ans; cout<<endl; while(ans=='y') { cout<<"Enter ur option (1-check balance, 2-deposit, 3-withdraw)"<<endl; cin>>opt; cout<<endl; switch(opt) { case 1: m[i].check_balance(); break; case 2: m[i].deposit_amount(); break; case 3: m[i].withdraw(); break; deafault: cout<<"Wrong Option"<<endl; } cout<<"Do U want 2 continue for next withdrawl/ deposit/ balance-inquiry?"<<endl; cin>>ans; cout<<endl; } } } cout<<"Do U want 2 continue for any other account?"<<endl; cin>>ch; } getch(); } OUTPUT The no of records U want 2 be entered: 3 Enter the following Records Record 1 Name: Sarvesh Enter Account No: 123456 Enter the Account-type: Current Enter the balance amount: 91234567 4|Page
  • 5. OBJECT ORIENTED PROGRAMMINGS 2010 Record 2 Name: Prashant Enter Account No: 456789 Enter the Account-type: Saving Enter the balance amount: 90234567 Record 3 Name: Rajeev Enter Account No: 789012 Enter the Account-type: Current Enter the balance amount: 98765432 Clear-screen.............. Record 1 Name: Sarvesh Account No: 123456 Account-type: Current Balance amount: 91234567 Record 2 Name: Prashant Account No: 456789 Account-type: Saving Balance amount: 90234567 Record 3 Name: Rajeev Account No: 789012 Account-type: Current Balance amount: 98765432 Do u want 2 continue for any account? y Clear-screen... Enter ur account no 789012 Name: Rajeev Account No: 789012 Account-type: Current Balance amount: 98765432 Do U want 2 continue for any account-process(y/n)? y Enter ur option (1-check balance, 2-deposit, 3-withdraw) 1 Balance: 98765432 Do U want 2 continue for next withdrawl/ deposit/ balance-inquiry? y Enter ur option (1-check balance, 2-deposit, 3-withdraw) 2 Enter the amount U want to deposit: 67890543 Balance: 166655975 Do U want 2 continue for next withdrawl/ deposit/ balance-inquiry? y Enter ur option (1-check balance, 2-deposit, 3-withdraw) 3 Enter the amount U want to withdraw: 4567890 U have entered the wrong amount. Amount less than balance and multiple of 100 only can be withdrawn Amount withdrawn: 0 Balance: 166655975 Do U want 2 continue for next withdrawl/ deposit/ balance-inquiry? y Enter ur option (1-check balance, 2-deposit, 3-withdraw) 5|Page
  • 6. OBJECT ORIENTED PROGRAMMINGS 2010 3 Enter the amount U want to withdraw: 4567800 Amount withdrawn: 4567800 Balance: 162088175 Do U want 2 continue for next withdrawl/ deposit/ balance-inquiry? n Do U want 2 continue for any other account? n Q 2) Write an operator overloading program to write S3+=S2. 6|Page
  • 7. OBJECT ORIENTED PROGRAMMINGS 2010 #include<iostream.h> #include<conio.h> class numb { private: int i; public: numb() { i=10; } void operator++() { i=i+1; cout<<i<<endl; } }; void main() { numb n; clrscr(); int j; cout<<"How many times u want to increment the value?t"; cin>>j; for(int m=0;m<j;++m) {n.operator++(); } getch(); } OUTPUT 7|Page
  • 8. OBJECT ORIENTED PROGRAMMINGS 2010 How many times u want to increment the value? 8 11 12 13 14 15 16 17 18 // overloading prefix ++ incrementer operator for obtaining Fibonacci series #include<iostream.h> #include<conio.h> class fibonacci { private: unsigned long int f0, f1, fib; public: fibonacci(); //constructor void operator++(); void display(); }; fibonacci::fibonacci() { f0=0; f1=1; fib=f0+f1; } void fibonacci::display() { cout<<fib<<"t"; } void fibonacci::operator++() {f0=f1; f1=fib; fib=f0+f1; } 8|Page
  • 9. OBJECT ORIENTED PROGRAMMINGS 2010 void main() { clrscr(); fibonacci obj; int n; cout<<"How many fibonacci numbers are to be displayed? n"; cin>>n; for(int i=0; i<=n-1;++i) { obj.display(); ++obj; } getch(); } OUTPUT How many fibonacci numbers are to be displayed? 10 1 2 3 5 8 13 21 34 55 89 Q 3) Write an operator overloading program to Overload ‘>’ operator so as to find greater among two instances of the class. 9|Page
  • 10. OBJECT ORIENTED PROGRAMMINGS 2010 //overloading of comparison operators #include<iostream.h> #include<conio.h> class sample { private: int value; public: sample(); sample( int one); void display(); int operator > (sample obj); }; sample::sample() { value = 0; } sample::sample( int one) 10 | P a g e
  • 11. OBJECT ORIENTED PROGRAMMINGS 2010 { value = one; } void sample::display() { cout<<"value "<<value<<endl; } int sample::operator > (sample obja) { return (value > obja.value); } void main() { clrscr(); sample obja(20); sample objb(100); cout<<(obja>objb)<<endl; cout<<(objb>obja)<<endl; getch(); } OUTPUT 0 1 11 | P a g e
  • 12. OBJECT ORIENTED PROGRAMMINGS 2010 Q 4) WAP using Single and Multiple Inheritance. //single inheritance using array of objects #include<iostream.h> #include<conio.h> #include<stdio.h> #include<string.h> #include<iomanip.h> const int max=100; class basic_info { private: char name[30]; long int rollno; char sex; public: void getdata(); void display(); }; //end of class declaration class physical_fit:public basic_info { private: float height,weight; public: void getdata(); void display(); }; void basic_info::getdata() 12 | P a g e
  • 13. OBJECT ORIENTED PROGRAMMINGS 2010 { cout<<"ENTER A NAME ? n"; cin>>name; cout<<"ROLL No. ? n"; cin>>rollno; cout<<"SEX ? n"; cin>>sex; } void basic_info::display() { cout<<name<<" "; cout<<rollno<<" "; cout<<sex<<" "; } void physical_fit::getdata() { basic_info::getdata(); cout<<"HEIGHT ? n"; cin>>height; cout<<"WEIGHT ? n"; cin>>weight; } void physical_fit::display() { basic_info::display(); cout<<setprecision(2); cout<<height<<" "; cout<<weight<<" "; } void main() { clrscr(); physical_fit a[max]; int i,n; cout<<"HOW MANY STUDENTS ? n"; cin>>n; cout<<"ENTER THE FOLLOWING INFORMATION n"; for(i=0;i<=n-1;++i) { cout<<"RECORD : "<<i+1<<endl; a[i].getdata(); } cout<<endl; cout<<"_________________________________________________ n"; cout<<"NAME ROLLNO SEX HEIGHT WEIGHT n"; cout<<"_________________________________________________ n"; for(i=0;i<=n-1;++i) 13 | P a g e
  • 14. OBJECT ORIENTED PROGRAMMINGS 2010 { a[i].display(); cout<<endl; } cout<<endl; cout<<"_________________________________________________ n"; getch(); } OUTPUT HOW MANY STUDENTS? 3 ENTER THE FOLLOWING INFORMATION RECORD: 1 ENTER A NAME? Sarvesh ROLL No. ? 13 SEX? M HEIGHT? 174 WEIGHT? 59 RECORD : 2 ENTER A NAME? Prashant ROLL No. ? 19 SEX ? M HEIGHT? 166 WEIGHT? 63 RECORD : 3 ENTER A NAME ? Rajeev ROLL No. ? 23 SEX ? M HEIGHT? 14 | P a g e
  • 15. OBJECT ORIENTED PROGRAMMINGS 2010 164 WEIGHT? 53 _________________________________________________ NAME ROLLNO SEX HEIGHT WEIGHT _________________________________________________ Sarvesh 13 M 174 59 Prashant 19 M 166 63 Rajeev 23 M 164 53 _________________________________________________ #include<iostream.h> #include<conio.h> #include<stdio.h> #include<string.h> class baseA { public: int a; }; class baseB { public: int a; }; 15 | P a g e
  • 16. OBJECT ORIENTED PROGRAMMINGS 2010 class baseC { public: int a; }; class derivedD: public baseA,public baseB, public baseC { public: int a; }; void main() { clrscr(); derivedD objd; objd.a=10; //local to the derived class cout<<"n VALUE OF a IN THE DERIVED CLASS = "<<objd.a; cout<<endl; cout<<"n VALUE OF a IN THE baseA = "<<objd.baseA::a; cout<<endl; cout<<"n VALUE OF a IN THE baseB = "<<objd.baseB::a; cout<<endl; cout<<"n VALUE OF a IN THE baseC = "<<objd.baseC::a; cout<<endl; cout<<endl; getch(); } #include<iostream.h> #include<conio.h> #include<stdio.h> #include<string.h> class baseA { public: int a; }; class baseB 16 | P a g e
  • 17. OBJECT ORIENTED PROGRAMMINGS 2010 { public: int a; }; class baseC { public: int a; }; class derivedD: public baseA,public baseB, public baseC { public: int a; }; void main() { clrscr(); derivedD objd; objd.a=10; objd.baseA::a=20; objd.baseB::a=30; objd.baseC::a=40; cout<<"n VALUE OF a IN THE DERIVED CLASS = "<<objd.a; cout<<endl; cout<<"n VALUE OF a IN THE baseA = "<<objd.baseA::a; cout<<endl; cout<<"n VALUE OF a IN THE baseB = "<<objd.baseB::a; cout<<endl; cout<<"n VALUE OF a IN THE baseC = "<<objd.baseC::a; cout<<endl; cout<<endl; getch(); } OUTPUT VALUE OF a IN THE DERIVED CLASS = 10 VALUE OF a IN THE baseA = 20 VALUE OF a IN THE baseB = 30 17 | P a g e
  • 18. OBJECT ORIENTED PROGRAMMINGS 2010 VALUE OF a IN THE baseC = 40 18 | P a g e