| Date of Quiz: | Fri Nov-10 |
Note: This is a programming quiz. You must use Visual C++. You must begin with a new project, and you may not use any notes or any pre-written code.
Your task is to write the missing portions of the code below (note that this is precisely the code which we wrote in class and reviewed as homework for the past two nights):
// quiz8.cppSee Course Home Page.
// Demonstrates fundamentals of using vectors#include <iostream.h>
#include <stdio.h>
#include "apvector.h"typedef apvector<int> intVector;
void printVector(intVector v)
{
// You Write This -- Part 1 of 3
}bool occursInVector(intVector v,int checkNum)
{
// You Write This -- Part 2 of 3
}void main()
{
intVector v;
int vSize, i, elementCounter, oldSize, checkNum;elementCounter = 0;
oldSize = 0;
while (true)
{
cout << "Enter size of vector (<0 to quit): ";
cin >> vSize;// if <0, then quit
if (vSize < 0)
{
return;
}// make the vector this size
v.resize(vSize);// initialize the newly-created elements of the vector
// (These are the ones starting with v[oldSize]// YOU WRITE THIS -- Part 3 of 3
// print the newly-sized vector
printVector(v);// Check if a number occurs in it
cout << "Enter # to check for: ";
cin >> checkNum;if (occursInVector(v,checkNum))
{
cout << "It does occur in the vector" << endl;
}
else
{
cout << "It does not occur in the vector" << endl;
}
}
getchar();
}