Docsity

Cheat notes object oriented programming, Cheat Sheet of Object Oriented Programming

Toggle sidebar
bg1
GC WOMEN UNIVERSITY SIALKOT
Department of Computer Science
Lab task 2 (Semester 3rd Fall – 2021)
Course Title: Object Oriented programming Course Code: CMP-211
Student Name: _______________ Instructor’s Signature: _______
Student Roll No: Info.tech-200/Comp.Sc-200__
Instructions:
ļ‚·Work on this lab task individually.
ļ‚·You have to submit this task via email on your instructor’s email id
ļ‚·Anyone caught being indulged in the act of plagiarism would be awarded ā€œ0ā€ Marks in
this lab.
Task to perform:
Task 1. Create a class named 'Student' with a string variable 'name' and an integer variable 'roll_no'.
Assign the value of roll_no as '20021' and that of name as "Sidra" by creating an object of the class
Student.
Task 2. Write a program that would print the information (name, year of joining, salary, address) of
three employees by creating a structure named 'Employee'. The output should be as follows:
Name Year of joining Address
Asma 2020 64C- ModelTown
Ishaq 2000 68D- Islamia Park
Sidra 2016 26B- Masooda Bad
Task 3. Print the sum, difference and product of two complex numbers by creating a structure named
'Complex' with separate functions for each operation whose real and imaginary parts are entered by
the user.
Task 4. Write a C++ program to add two fractions and display the result fraction. Your program will
prompt the user to input fraction 1 and fraction 2. The numerator and denominator of each fraction
are input separately by space. See the example output below. You will need to use a C++ structure
to define a fraction. The structure has two members: numerator and denominator.
Enter fraction 1(numerator denominator): 1 2
Enter fraction 2(numerator denominator): 2 5
Result: 9/10
Task 5. Add two distances in inch-feet by creating a class named 'AddDistance'.
pf2

Partial preview of the text

Download Cheat notes object oriented programming and more Cheat Sheet Object Oriented Programming in PDF only on Docsity!

GC WOMEN UNIVERSITY SIALKOT

Department of Computer Science

Lab task 2 (Semester 3rd^ Fall – 2021)

Course Title: Object Oriented programming Course Code: CMP- Student Name: _______________ Instructor’s Signature: _______ Student Roll No: Info.tech-200/Comp.Sc-200__

Instructions:

ļ‚· Work on this lab task individually.

ļ‚· You have to submit this task via email on your instructor’s email id

([email protected]).

ļ‚· Anyone caught being indulged in the act of plagiarism would be awarded ā€œ0ā€ Marks in

this lab.

Task to perform:

Task 1. Create a class named 'Student' with a string variable 'name' and an integer variable 'roll_no'. Assign the value of roll_no as '20021' and that of name as "Sidra" by creating an object of the class Student. Task 2. Write a program that would print the information (name, year of joining, salary, address) of three employees by creating a structure named 'Employee'. The output should be as follows: Name Year of joining Address Asma 2020 64C- ModelTown Ishaq 2000 68D- Islamia Park Sidra 2016 26B- Masooda Bad Task 3. Print the sum, difference and product of two complex numbers by creating a structure named 'Complex' with separate functions for each operation whose real and imaginary parts are entered by the user. Task 4. Write a C++ program to add two fractions and display the result fraction. Your program will prompt the user to input fraction 1 and fraction 2. The numerator and denominator of each fraction are input separately by space. See the example output below. You will need to use a C++ structure to define a fraction. The structure has two members: numerator and denominator. Enter fraction 1(numerator denominator): 1 2 Enter fraction 2(numerator denominator): 2 5 Result: 9/ Task 5. Add two distances in inch-feet by creating a class named 'AddDistance'.

Task 6. Create a Structure of date(Day, Year, Month) and Name(First name, Last Name) and use these in student structure for name and date of brith. Task 7. Store information of multiple students using structures using array of structures and display the information stored. Task 8. Write a C++ Program to swap two numbers using call by reference. Task 9. Write a C++ program to find area of circle using formula pi*r2. take the value of pi as default argument in function. Task 10. Write a program that asks for a user first name and last name separately. The program must then store the users full name inside a single string and out put it to the string. i.e. Input: John Smith Output: John Smith ā˜… Modify the program so that it then replaces every a, e, i , o, u w/ the letter z. i.e. John Smith -> Jzhn Smzth ā˜…ā˜… Modify the Program so that it reverses the users name i.e. John Smith -> htimS nhoJ Task 11. Write a program to overload the max function (1) Find the max number from three numbers. (2) Find the max string from three strings.