Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

object oriented programming, Essays (university) of Object Oriented Programming

In this topic i will tell about how to add number in oop

Typology: Essays (university)

2019/2020

Uploaded on 06/15/2020

abdul-rehma
abdul-rehma 🇵🇰

5

(1)

2 documents

Partial preview of the text

Download object oriented programming and more Essays (university) Object Oriented Programming in PDF only on Docsity! Bahria University, Lahore Campus Department of Computer Science Lab Journal 04 (Spring 2020) Course: Object Oriented Programming - Lab Date: _______________ Course Code: CSL-210 Max Marks: 10 Faculty’s Name: Ms. Zupash Awais Name: _____________________ Enroll No: ___________________ Class: ______________ Objective(s): Upon completion of this lab session, learners will be able to:  Array of Objects  Const Members Lab Tasks: Task 1 Create a class called time that has separate int member data for hours, minutes, and seconds. One constructor should initialize this data to 0, and another should initialize it to fixed values. Another member function should display it, in 11:59:59 format. #include<iostream> using namespace std; class time { int hour; int min; int second; public: time() :hour(0), min(0), second(0) { } time(int a, int b, int c) { hour = a; min = b; second = c; if (hour <= 0 || hour >= 23) hour = 0; if (min <= 0 || min >= 59) min = 0; if (second <= 0|| second >= 59) second = 0; } void display() { cout << hour << ":" << min << ":" << second << endl; % Enrollment Number: ____________________________ } }; void main() { time t(30, 9, 7); t.display(); } Task 2 Write a program with a class that contains following data members  Id  name  marks Create and array of objects of size 10. Create a function read() to take input from user. Create a function to calculate percentage of each student. Then create a function that displays the student id and name of the student with the lowest percentage. #include<iostream> #include<string> using namespace std; class student { int marks; int id; string name; public: student(); void read(); }; student::student() { marks = 0; id = 0; name = " "; } student::student() { marks = 0; id = 0; name = " "; } void student::read() { } void main() { student p[10]; Page 2 of 4