Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a C++ program that has three files: header, implementation, and main files. The header file contains the following functions' prototypes: 1. void fillArray(int list[],
Write a C++ program that has three files: header, implementation, and main files. The header file contains the following functions' prototypes:
1. void fillArray(int list[], const int listSize) This function reads the elements of the array from user.
2. void printArray(int list[], const int listSize) This function prints the elements of the array to the screen
3. int searchArray(const int list[], const int listSize, int number) This function searches for a number in the array and returns its index (or -1 if not found).
4. void MaxMin(const int list[], const int listSize, int &max,int &min) Function to find and return the maximum and minimum elements in the array.
5. void incrementWithX(int list[], const int listSize, int element, int X)
This function searches for an element in the array and increments it with X. Hint: Call searchArray() in order to find the index to the required element.
6. bool isExist(const char c[],char d)
This function receives a string and checks if the given character d exists in it or not.
7. int countDigits(const char [])
This function returns the number of digits in the string.
8. void replaceAndCapitalize(char[])
This function takes a string and replace each space into star then capitalize the following character.
For example,
Char c[50]=hello c++ lab
After calling the function it will be hello*C++*Lab
Hint: use these functions: int toupper (char c)
e.g:
char upper;
upper = toupper(temp);
int tolower (char c)
Converts c to its uppercase equivalent if c is a lowercase letter and has
an uppercase equivalent. If no such conversion is possible, the value returned is c unchanged.
Converts c to its lowercase equivalent if c is a lowercase letter and has an
uppercase equivalent. If no such conversion is possible, the value returned is c unchanged implementation.cpp file contains the definitions for the functions which their prototypes are declared in header.h
In main.cpp:
Define two arrays, one of them is array of integers with size 5, and the other array
of characters(string). Give initial values to its elements.
Test your functions in the main program. A menu-driven program with the following menu could be implemented for this purpose.
1. Read integer Array
2. Print integer Array
3. Max and Min values in the integer Array
4. increment an element of the integer array with X value 5. Check if a character is existing in the string or not
6. Count the number of digits in the string.
7. Manipulate the string
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started