Latest Activity In Study Groups

Join Your Study Groups

VU Past Papers, MCQs and More

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.

Assignment No. 04 Total Marks: 20
Semester: Spring 2015
CS304: Object Oriented Programming Due Date: 17/08/2015


Please read the following instructions carefully before submitting assignment. It should be clear that your assignment will not get any credit if:

The assignment is submitted after due date.

The submitted assignment does not open or file is corrupt.

Assignment is copied(partial or full) from any source (websites, forums, students, etc)

Note: You have to upload only .cpp file. Assignment in any other format (extension) will not be accepted and will be awarded with zero marks. For example, if you submit code in .doc (Microsoft Word Document) or .txt files or

.exe file, no reward will be given in any case.


The objective of this assignment is to provide hands on experience of:


Generic Programming Polymorphism


Code should be properly indented and well commented.

Follow C/C++ guide lines while writing variable names & function names etc. Use only Dev-C++ for this assignment.

For any query about the assignment, contact at


Problem Statement:

In this assignment, write a generic code that will work for all data types. You are required to write a template function named add() in your program. This function will take two arguments of template type that will add these passed parameters and return the result of addition. i.e.


T add (T value1, T value2)

Within main() function, you are required to call the template function add() for int, float and Complex types. Now, display the result of all these functions.

int v1 = 5, v2 = 6 ; float x = 2.3, y = 3.5 ;

Complex c1(2, 3), c2(2, 3), t ;

Note: For complex numbers, you will have to create a user defined type.

Sample output of the program:

Views: 9469


Replies to This Discussion

chaly students discusion start kry ...phli ko submit krway hoy 2 din nh hoy or pir a gai

Kb khtm ho giii assignments mjhe assignmentaria ho gaya ha doctor ne strictly advise kiya ha assignments se door rehne k liye specially CS-304 is subject se ziyada serious condition ho skti ha.... 

Yeh assignments ke number add hujainge final papers main ....:)

to batoo na kasy bny ge ab y :(

hahahahahaha snober sis how funny

mere ko doctor n bola vu s hi door rhooo 

vu ya cs304 se door rehny ki zaroorat nahiii... ning choor do bukhaar utter jaeey ga

well said

ha ha ha ha ha ha ha


ha ha ha
bas ye last ha Sayyeda Snober g


Looking For Something? Search Below

Top Trends 

Latest Activity

Aijaz khan updated their profile
18 minutes ago
Aijaz khan joined + M.Tariq Malik's group
20 minutes ago
Profile IconRibqa, Muhammad Rizwan Ansari, Muhammad Imran and 3 more joined Virtual University of Pakistan
32 minutes ago
Huma noor liked + M.Tariq Malik's group ENG101 English Comprehension
40 minutes ago
Melissa Dorn replied to + M.Tariq Malik's discussion Reality of Modern Co-Education System of Pakistan
15 hours ago
Profile IconSamrina, Malaika Iqbal, Tahir Abbas and 2 more joined Virtual University of Pakistan
memon added a discussion to the group MGT610 Business Ethics
Profile IconStudent, Batool, Suha Khan and 3 more joined Virtual University of Pakistan

© 2022   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service