Question
you will need to create the following functions. Place the definitions in array.cpp, place the function prototypes in array.h, and invoke the functions (call them)
you will need to create the following functions. Place the definitions in array.cpp, place the function prototypes in array.h, and invoke the functions (call them) in main.cpp. Dont delete any statements that are already in the files. You should label the output of your test, such as the list after insertion: etc.
---------------------------------------------------------------
intnumOfEven(intlist[],intsize) // compute and return the number of even integers in list
boolinsert(intlist[],int&size,intnewInt,intposition) // insert newInt into the list at index position and update the size of the list.
------------------------------------------------------------------------------------
Lets discuss insert for a moment. The value position is the index where newInt should be inserted. So, 0 (zero) is the first location and size 1 is the last location. To place newInt, you will have to make room for it by moving the current values over by one, unless newInt is to be placed at the end.
Suppose you have the following array: 3 5 2 7. Then the size is 4. Suppose newInt is 6, and position is 2. Then the new size is 5, and the updated array is: 3 5 6 2 7. If the position is equal to size, place newInt at the end. If your function successfully inserts newInt into the array, return true. If position is greater than size or less than zero, leave the array unchanged and return false.
Create a Makefile for the project and use make to build it. Please dont forget the supplied.o when generating the executable.
-------------------------------------------------------------
Here are the files below.
---------------------------------------
/array.cpp
#include "array.h"
//put the implementations of your assigned functions here
// *** End of array.cpp ***
#ifndef ARRAY_H
#define ARRY_H
//array.h
#include
#include
#include
using namespace std;
/* These functions are already written and can be called to test out your code */
void build(int list[], int size); //supplied
void display(int list[], int size); //supplied
/* *****************YOUR TURN! ******************************** */
//Write your function prototype here:
#endif
//main.cpp
#include "array.h"
using namespace std;
const int CAP = 100;
int main()
{
int list[CAP];
int size = 10;
build(list, size); // Place random numbers in list.
display(list, size);
//PLEASE PUT YOUR CODE HERE to call the function assigned
display(list, size);
return 0;
}
// *** End of main.cpp ***
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