Skip to content
VUBuddy

CS201P All Labs

Introduction to Programming (Practical) PDF 232 KBUpdated 23 Oct 2026
Quiz CS201P All Labs PDF 232 KB
vubuddy.com
Type
Quiz
Course
CS201P Introduction to Programming (Practical)
Size
PDF 232 KB
Updated
23 Oct 2026
Free download 0 of 3 used today
Download free · 232 KB

You get 3 free files a day on the website. Add the Chrome extension for 30 a day.

Unlimited downloads in the Android app Get it free on Google Play

Preview text

Text from pages 1, 2, 3 of 32. Download the file for all 32 pages.

CS201-Lab-Exercise - this is the latest lab from cs201, you can practice it and also another cs students

Introduction to programming /c++ (Virtual University of Pakistan)

Scan to open on Studocu

CS201-Lab-Exercise - this is the latest lab from cs201, you can practice it and also another cs students

Introduction to programming /c++ (Virtual University of Pakistan)

Scan to open on Studocu

Lab # 13

You need to write a program in which the following concepts must be implemented. Write a template function name “Add” which accepts two arguments of the same type int, float, double from the user then add those arguments, return their sum and display them on the screen. Write a class named as firstClass, also write another class named as secondClass which should be nested inside the firstClass. Define a function named displayMessage inside the secondClass, this method should print the message “Inside the second class” on the screen. In the main function create the object of the secondClass and invoke the displayMessage method using the secondClass object.

Solution:

class firstClass {

public:

class secondClass { public: void displayMessage(){ cout<< " Function inside the inner class" <<endl;

template<class T> T Add (T x, T y) { return x + y;

int main() {

firstClass :: secondClass object; object.displayMessage();

int integerOne = 3, integerTwo = 5; float floatOne = 12.34, floatTwo = 894.4; double doubleOne = 1236.58, doubleTwo = 8945.685;

cout<< " Addition of Two integer Number is = " << Add(integerOne,integerTwo) <<endl; cout<< " Addition of Two floating point Number is = " << Add(floatOne,floatTwo) <<endl; cout<< " Addition of Two double Number is = " << Add(doubleOne , doubleTwo) <<endl;

return 0;

All CS201P files →
CS201P Introduction to Programming (Practical) All CS201P handouts, past papers, quizzes and MCQs in one place. Open course page

Get more out of VUBuddy, for free

Android app Free on Google Play
  • Unlimited downloads
  • The explanation behind every MCQ answer
  • Study offline on slow data
Get the Android app
Chrome extension Free on the Chrome Web Store
  • 30 downloads a day instead of 3
  • Sign in and buy Pro Semester here
Add to Chrome

One Pro Semester membership works in both the extension and the app.