Object Oriented Programming C++

Object Oriented Programming Practical 6

Object Oriented Programming Practical 6 Question 1 Write a C++ program to calculate area of Rectangle using Inline function. rectangle.cpp C #include <iostream.h> #include <conio.h> inline int calculateArea(int length, int width) { return length * width; } void main() { int length, width; cout << "Enter the length of the rectangle: "; cin >> length; […]

Object Oriented Programming Practical 6 Read More »

Object Oriented Programming Practical 5

Object Oriented Programming Practical 5 Question 1 Write a program to find area of circle such that the class circle must have three functions namely:a)read() to accept the radius from user.b)compute() for calculating the areac)display() for displaying the result.(Use Scope resolution operator) circle.cpp C #include<iostream.h> #include<stdio.h> #include<conio.h> class circle { public: int radius; float area;

Object Oriented Programming Practical 5 Read More »

Object Oriented Programming Practical 4

Object Oriented Programming Practical 4 Question 1 Define a class Room with data members length, breadth and height. Member function calculate_area () and calculate_volume(). Calculate the area and volume of room. Define the member function inside the class. room.cpp C #include<iostream.h> #include<stdio.h> #include<conio.h> class room { public: int length,breadth,height; void accept() { cout<<"nEnter length of

Object Oriented Programming Practical 4 Read More »

Object Oriented Programming Practical 3

Object Oriented Programming Practical 3 Question 1 Calculate average of two numbers using explicit type casting average.cpp C #include<iostream.h> #include<conio.h> void main() { int num1, num2; float average; cout << "Enter the first number: "; cin >> num1; cout << "Enter the second number: "; cin >> num2; average=(float)(num1+num2)/2; cout<<"Average is: "<<average; getch(); } #include<iostream.h>

Object Oriented Programming Practical 3 Read More »

Object Oriented Programming Practical 2

Object Oriented Programming Practical 2 Question 1 Write a C++ program to access the global variable using scope resolution operator. global.cpp C #include<iostream.h> #include<conio.h> int num=100; void main() { clrscr(); int num; cout<<"Enter number: "; cin>>num; cout<<"Value of number inside main is: "<<num<<endl; cout<<"Value of number outside main is: "<<::num<<endl; getch(); } #include<iostream.h> #include<conio.h> int

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 »