Object Oriented Programming C++

Object Oriented Programming Practical 6

Object Oriented Programming Practical 6 Question 1 Write a C++ program to create a class “Number” having data members n1 and n2 and perform mathematical operations like addition, subtraction, multiplication and division on two numbers using inline functions. number.cpp C #include <iostream> #include <conio.h> class Number { private: int n1, n2; public: void accept() { […]

Object Oriented Programming Practical 6 Read More »

Object Oriented Programming Practical 5

Object Oriented Programming Practical 5 Question 1 Write a C++ program to declare a class “staff’ having data members name, basic salary, DA, HRA and calculate gross salary. Accept and display data for one staff. Where DA=74.5% of basic HRA= 30% of basic. Gross_salary=basic+HRA+DA staff.cpp C #include <iostream.h> #include <conio.h> class staff { private: char

Object Oriented Programming Practical 5 Read More »

Object Oriented Programming Practical 4

Object Oriented Programming Practical 4 Question 1 Write a program to define a class student having data members name and roll no. Accept and display data for one object. Define the member function inside the class. student.cpp C #include <iostream.h> #include <conio.h> class Student { private: char name[30]; int rollNo; public: void acceptData() { cout

Object Oriented Programming Practical 4 Read More »

Object Oriented Programming Practical 3

Object Oriented Programming Practical 3 Question 1 Find the area of the rectangle by casting double data into float and int type. area.cpp C #include<iostream.h> #include<conio.h> void main() { double l,w; float area_float; int area_int; cout << "Enter the length of rectangle: "; cin >> l; cout << "Enter the width of rectangle: "; cin

Object Oriented Programming Practical 3 Read More »

Object Oriented Programming Practical 2

Object Oriented Programming Practical 2 Question 1 Write a C++ Program which show the use of function outside the class using scope resolution operator function.cpp C #include<iostream.h> #include<conio.h> class MyClass { public: void display(); }; void MyClass::display() { cout << "This function is outside class"<<endl; } void main() { clrscr(); MyClass obj; obj.display(); getch(); }

Object Oriented Programming Practical 2 Read More »

Object Oriented Programming Practical 1

Object Oriented Programming Practical 1 Question 1 Write a C++ program to evaluate the following expressions: X=(-b-(b2-4ac))/2a expression.cpp C #include<iostream.h> #include<conio.h> #include<math.h> void main() { clrscr(); int a,b,c,d; cout<<"Enter value of a,b and c"<<endl; cin>>a>>b>>c; d=(-b-(b*b-4*a*c))/(2*a); cout<<"Value= "<<d<<endl; getch(); } #include<iostream.h> #include<conio.h> #include<math.h> void main() { clrscr(); int a,b,c,d; cout<<"Enter value of a,b and c"<<endl;

Object Oriented Programming Practical 1 Read More »