0% found this document useful (0 votes)
20 views

Assignment 4

The document provides instructions for an assignment on programming fundamentals. It asks students to write a C++ program with multiple functions to: 1. Compress an integer array by removing values at odd indexes and returning the compressed array. 2. Design a phonebook storing names and contact numbers by reading from a text file. Implement functions to count contacts, capitalize names, display all names, search by name and display number, and optionally sort the array.

Uploaded by

Rooshan Javed
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Assignment 4

The document provides instructions for an assignment on programming fundamentals. It asks students to write a C++ program with multiple functions to: 1. Compress an integer array by removing values at odd indexes and returning the compressed array. 2. Design a phonebook storing names and contact numbers by reading from a text file. Implement functions to count contacts, capitalize names, display all names, search by name and display number, and optionally sort the array.

Uploaded by

Rooshan Javed
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

University of Central Punjab

Assignment-4

Programming Fundamental (Spring 2023) : 20 Marks

Date: 21-06-2023 Due Date: 30-06-2023


Instructions:
You are not allowed to use anything other than pointers and dynamic memory.
1. One function should perform one functionality only.
2. If plagiarism found, zero marks will be awarded.

Note : You have to submit only one .cpp files with as many functions as
required.

Write a C++ program that make use of functions to implement the following concepts. Make Sure the
program must be a menu driven where option 1 implements Question1 and option 2 implements
Question 2.

Question 1. Write a function that receives an integer array of any size and compress it in such a way
that all the values at the odd indexes of that array get removed from that array. Return the compressed
array.
Sample Run 1:
Input size: 7
Input array: 2 4 5 20 13 18 90
After compressing, the above array is: 2 5 13 90
Question2. Your task is to design a phonebook storing names and person contact numbers in a single
2d array or multiple as you wish by reading data from sample file given below:
(Option: You can fix the column size of your choice that can hold the data of each row, or you can make
use of jagged arrays or you can ask the same column size for all the users)

phonebook.txt
Fahad: 0333-6782316 sarmad:
0321-901672
mahad:0304-9876421 And
so on…

There can be any number of names so create row_size by counting rows from file by reading using loop.
Now once the TWO-D array gets created and data is read in two-d array/s, implement the following
using functions:
a) Count and tell the number of persons whose contacts are saved.
b) Capitalize all the letters in the names of all the persons.
c) Display the names of all the persons in the list
d) Search a person by name and display his/her contact number if exists
e) Optional: Sort the above array by names

You might also like