BSCS 2A OOP Lab 3
BSCS 2A OOP Lab 3
Lab Manual
for
Object Oriented Programming
Page 1 of 4
Lab Manual 3
Objectives:
After performing this lab, students shall be able to:
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.
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.
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