Diploma Computer/IT

Object Oriented Programming Practical 16

Object Oriented Programming Practical 16 Question 1 Write a C++ program to declare a class “Book” containing data members book_name, auther_name, and price . Accept this information for one object of the class using pointer to that object. book.cpp C #include<iostream.h> #include<stdio.h> #include<conio.h> class book { public: int price; char book_name[50],author_name[50]; void accept() { cout<<"nEnter […]

Object Oriented Programming Practical 16 Read More »

Object Oriented Programming Practical 15

Object Oriented Programming Practical 15 Question 1 Write a program which show the use of constructor in derived class. car.cpp C #include<iostream.h> #include<conio.h> #include<string.h> class car { char car_type[100]; public: car(char c_type[30]) { strcpy(car_type,c_type); } void display() { cout<<"nCar c_type: "<<car_type; } }; class brand:public car { float speed; char brand_name[50]; public: brand(float sp,char name[30],char

Object Oriented Programming Practical 15 Read More »

Object Oriented Programming Practical 14

Object Oriented Programming Practical 14 Question 1 Write a C++ program to implement the concept of virtual base class for following figure. student.cpp C #include<iostream.h> #include<conio.h> class student { char name[50]; public: void accept() { cout<<"nEnter name of student: "; cin>>name; } void display() { cout<<"nName of student: "<<name; } }; class test:virtual public student

Object Oriented Programming Practical 14 Read More »

Object Oriented Programming Practical 13

Object Oriented Programming Practical 13 Question 1 Write a C++ program to implement given class hierarchy. player.cpp C #include<iostream.h> #include<conio.h> class player { public: char name[50]; int matches; void accept() { cout<<"Enter name of player: "; cin>>name; cout<<"Enter number of matches: "; cin>>matches; } void display() { cout<<"Name of player: "<<name<<endl; cout<<"Number of matches: "<<matches<<endl;

Object Oriented Programming Practical 13 Read More »

Object Oriented Programming Practical 12

Object Oriented Programming Practical 12 Question 1 Write a C++ program to calculate the area and perimeter of rectangles using concept of inheritance. rectangle.cpp C #include<iostream.h> #include<conio.h> class Area { public: void area(int x,int y) { int a=x*y; cout<<"nArea = "<<a; } }; class Perimeter { public: void perimeter(int x,int y) { int p=2*(x+y); cout<<"nPerimeter

Object Oriented Programming Practical 12 Read More »

Object Oriented Programming Practical 11

Object Oriented Programming Practical 11 Question 1 Write a C++ program to define a class “Student” having data members roll_no, name. Derive a class “Marks” from “Student” having data members m1,m2,m3, total and percentage. Accept and display data for one student. student.cpp C #include<iostream.h> #include<conio.h> class student { int rollno; char name[100]; public: void accept()

Object Oriented Programming Practical 11 Read More »

Object Oriented Programming Practical 10

Object Oriented Programming Practical 10 Question 1 WAP to declare a class student having datamembers as name and percentage .Write constructor to initialise these data members. Accept and display data for one object. student.cpp C #include<iostream.h> #include<conio.h> #include<string.h> class Student { private: char name[50]; float percentage; public: Student(char n[50], float p) { strcpy(name,n); percentage=p; }

Object Oriented Programming Practical 10 Read More »

Object Oriented Programming Practical 9

Object Oriented Programming Practical 9 Question 1 Write a Program to declare a class birthday having data member day, month and year. Accept this info for object using pointer to array of object and display it. birthday.cpp C #include<iostream.h> #include<conio.h> class Birthday { private: int day,month,year; public: void accept() { cout << "Enter day: ";

Object Oriented Programming Practical 9 Read More »

Object Oriented Programming Practical 8

Object Oriented Programming Practical 8 Question 1 Write a Program to calculate weight of object at different planets using formula weight=m*g, Where m=mass of object G=gravitational force Declare g as static member variable. weight.cpp C #include <iostream.h> #include <conio.h> class Planet { public: static double g; static void setGravity(double gravity) { g = gravity; }

Object Oriented Programming Practical 8 Read More »

Object Oriented Programming Practical 7

Object Oriented Programming Practical 7 Question 1 WAP to declare a class calculation. Display addition, subtraction, multiplication, division of two numbers. Use friend function. operations.cpp C #include <iostream.h> #include <conio.h> class Number { private: int n1, n2; public: friend int add(int a,int b); friend int subtract(int a,int b); friend int multiply(int a,int b); friend float

Object Oriented Programming Practical 7 Read More »