Department of Computer Science & Engineering
Semester III
OOPs With C++(PCS-307)
Q1. Write a C++ program to create a class called StaticDemo and
overload funcDemo() static member function.
static void funcDemo(string,int) truncate a string to a certain
number of words.
Example
"The quick brown fox jumps over the lazy dog" , 4
Output :
The quick brown fox
static void funcDemo(string) count and print number of
palindrome in a passing string.
static void funcDemo(int,string) chop a string into chunks of a
given length.
Example:
2, "INFORMATION"
Output :
IN FO RM AT IO N
Example:
3, "INFORMATION"
Output :
INF ORM ATI ON
In main function invoke functions and perform the above task.
Q3. Write a C++ program to create a class called ArrayDemo
and overload arrayFunc() function.
void arrayFunc(int [], int, int) to find a pair of elements
(indices of the two numbers) from an given array whose
sum equals a specific target number.
Example
Array numbers= [10,20,10,40,50,60,70], size=7, target=50
Output: 3, 4
void arrayFunc(int ar1[], int size ,int arr2[], int size2) to
merge two arrays and removes all duplicates elements.
Example
ar1= [1, 2, 3] , size=3 , ar2= [2, 30, 1] , size=3
Output:
[3, 2, 30, 1]
Q4. Write a C++ program to create a class called StaticDemo
and with following static member functions.
static void numCal(int,char)If passing character is ‘p’ then
print square of passing number otherwise cube of a number
static void showValue(int,int,char)If passing character is
‘a’ then print addition of numbers otherwise print Ascii
value of a passing character.
static void equals(string,string)Check whether passing
strings are equal or not.
In main function invoke all static member functions and
perform the above task.