0% found this document useful (0 votes)
12 views4 pages

BSCS 2A OOP Lab 3

The lab manual for Object Oriented Programming at National University of Computer and Emerging Sciences outlines objectives and problems for students to solve using C++. Key topics include memory management, dynamic arrays, encryption, and matrix manipulation. The manual provides specific programming tasks such as the Queen Problem, Fibonacci series, and message encryption/decryption.

Uploaded by

mariamqadeem181
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views4 pages

BSCS 2A OOP Lab 3

The lab manual for Object Oriented Programming at National University of Computer and Emerging Sciences outlines objectives and problems for students to solve using C++. Key topics include memory management, dynamic arrays, encryption, and matrix manipulation. The manual provides specific programming tasks such as the Queen Problem, Fibonacci series, and message encryption/decryption.

Uploaded by

mariamqadeem181
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

National University of Computer and Emerging Sciences

Lab Manual
for
Object Oriented Programming

Course Instructor Dr Saira Karim


Lab Instructor(s) Ms. Mamoona Akbar
Ms. Sonia Anum
Section OOP BSCS-2A
Semester Spring 2022

Department of Computer Science


FAST-NU, Lahore, Pakistan

Page 1 of 4
Lab Manual 3

Objectives:
After performing this lab, students shall be able to:

 Memory leak concept.


 Dangling pointer
 Double pointer 2-D array.

Problem 1
Write a C++ program “Queen Problem”. In this game we have three cards (Jack, King, Queen).
Cards each time shuffle. Player has to guess where the queen has been placed. If the player guess
is correct he will be given a reward three times of his penalty. Otherwise deduct a penalty to its
account. Initially player has $100.
Before each guess queen ask user how much penalty charge if you guess wrong.

Hint: used rand function for shuffling.


Make players function to do this functionality.
a) Make static array of cards.
b) Make dynamic array of cards. Don’t delete pointer. // why memory size increase at this step.
c) Make dynamic array of cards. Delete pointer.
Open the window task manager and see how much memory consumed at each step.

Problem 2
Write a function “fibonacci series” that takes a number from user and find the Fibonacci series
of that number and return its address.
Hint: can’t use pointer in Fibonacci_series function.
Int *Fibonacci_series();

Problem 3

When sending or receiving messages the security of the message is very important. There are
several methods to secure the messages transmitted, one of them is encryption. Your program
should take a string sentence as input. Your task is to code two functions to keep the messages
secure. First you need to encrypt, making a function encrypt (string mystr). The string should be
encrypted by adding the length of string to each character. Then you need to decrypt the string by
making a function decrypt (string mystr), to reveal the original sentence.

Page 2 of 4
Sample Run:

Problem 4
i) Write a function char** AllocateMemory(int& rows, int& cols) that takes size of
matrix (rows and columns) from user, allocates memory for the matrix and return its
pointer.

ii) Write a function void InputMatrix(char** matrix, const int rows, const int cols)
which takes input the values in matrix from user(console).
iii) Write a function void DisplayMatrix(char** matrix, const int& rows, const int&
cols) that displays the matrix in proper format.

iv) Write a function that does the following:


 Creates three dynamic char arrays namely alphabets, numbers, and specialchar.
(Define the sizes yourself).
 Iterate the 2D array and separate alphabet elements and save them in the alphabets
array, separate number elements and save them in numbers array and separate special
character elements and save them in the specialchar array.
 The function returns the three arrays alphabets, numbers, and specialchar.
 Note: The three arrays should not consume any extra space. Resize the arrays
accordingly.

For example, if the Sample Matrix is

A 1 v @

+ 9 s 6

P # ^ 4

Page 3 of 4
Your function will return the following arrays:

alphabets = A v s P
numbers = 1 9 6 4
specialchar = @ + # ^

Page 4 of 4

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy