Answered step by step
Verified Expert Solution
Link Copied!

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 readArray(int a[],

Write a C++ program that has three files: header, implementation, and main files. The header file contains the following functions' prototypes:
1. void readArray(int a[], constint size)
This function reads the elements of the array from user.
2. void printArray(constint a[], const int size)
This function prints the elements of the array to the screen
3. double Array_Average(constint a[], const int size)
This function calculates the average of the array and returns it.
4. void incrementByM(int a[], const int size, int M)
This function increments each element of the array by M
5. void incrementByM(int & a, int M)
This function increments specific element of the array by M
implementation.cpp file contains the definitions for the functions which their prototypes are declared in header.h
In main.cpp:
Define local int array of size 10. Give values to its elements using an initializer list.
Test your functions in the main program. A menu-driven program with the following menu could be implemented for this purpose.
1. Read Array.
2. Print Array.
3. Find average
4. Increment each element of the array by M.
5. Increment specific element of the array by M.
6. Exit.
Q.2... 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions