0% found this document useful (0 votes)
29 views2 pages

PF Lab Final Spring 2023 Slot 2

The exam contains two questions testing dynamic memory allocation and file input/output skills in C++. Question 1 involves reading integers into a dynamic array and filtering for prime numbers. Question 2 reads words from a file into a 2D character array and counts vowels, identifying rows with maximum counts. Correct handling of memory is required.

Uploaded by

Rooshan Javed
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)
29 views2 pages

PF Lab Final Spring 2023 Slot 2

The exam contains two questions testing dynamic memory allocation and file input/output skills in C++. Question 1 involves reading integers into a dynamic array and filtering for prime numbers. Question 2 reads words from a file into a 2D character array and counts vowels, identifying rows with maximum counts. Correct handling of memory is required.

Uploaded by

Rooshan Javed
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/ 2

PF Lab Final Examination Spring 2023

Time Slot: 3:00 to 4:30

Total Duration: 1 hour 30 minutes Marks:20+20


Note:
Each question carries equal marks.
The sample inputs/outputs are for reference only. Your code must be generic.
Submit zip file containing .cpp file/s on portal.

Question 1: Write a C++ program which reads positive integers that are greater
than 1 from standard input in a dynamic integer array whose size will be input by
user.
Write a function that should create another array dynamically and store in only
those values from input array which are not exactly divisible by any other of the
value in that array. The function should return the output array.
Display the resultant array using display function.

Note:

There must be No space wastage / memory leakage / dangling pointers.


Sample Run1:
Input size: 4
Input array values: 42 7 6 12
Output array contains the following elements: 7 6

Sample Run 2:
Input size: 3
Input array values: 5 5 25
Output array contains zero elements.
Question 2:

An Input file contains multiple words, where each word stored in a separate line.

Write a function in C++ that reads words from file in a dynamic two D array of
characters. Display the total number of vowels in each row. Also tell the row
number with the maximum number of vowels. (Note: There may have multiple
rows with the maximum vowel count)

If the sample Input file contains the following values:


Data.txt

Java
Python
C++
HTML
Cobol

Vowels Count in the output 2D array are:

Total vowels in row # 0: 2


Total vowels in row # 1: 1
Total vowels in row # 2: 0
Total vowels in row # 3: 0
Total vowels in row # 4: 2

Maximum vowel count: 2

Row index 0 has maximum vowels


Row index 4 has maximum vowels.

You might also like