CST 8116 FINAL COMPREHENSIVE EXAM
STUDY GUIDE WITH COMPLETE
SOLUTIONS
●● What is Moore's Law?
Answer: The capacity of ICs doubles roughly every 18 months
●● Which assigns the vector's last element with 99?
vector<int> myVector(15);
Answer: myVector.at(14)= 99;
●● Which reads an entire line of text into string myString?
Answer: getline(cin, myString);
●● What is written to the file, myfile.txt?
#include <iostream>
#include <fstream>
using namespace sld;
int main() {
,ofstream outFS;
string str;
cout << "Opening a fie" << endl;
outFS.open("myfile.tx");
if (outFS is_open()) {
cout << "Could not open fle myfile.txt." << endl;
return 1;
}
outFS << "This is test data" ;
outFS.close();
return 0;
}
Answer: This is test data
●● Which statement can be used instead of Statement 1?
clasa Sample {
public:
Sampie (int xValue = 0, int yValue = 0);
void ShowData();
};
int main () {
, Sample* sample1 = new Sample;
(*sample1).ShowData(); //Statement 1
Answer: (sample1) --> ShowData();
●● Which assigns the vector's first element with 99?
vector<int> myVector(4);
Answer: myVector.at(0) = 99;
●● Which XXX adds input values until a 0 is input?
int number;
int sum = 0;
do {
cin >> number;
sum= sum + number;
} while (XXX);
Answer: number ! = 0
●● If the input sets int x with 5 and int y with 7, what is the ending value
of z? z is declared as a boolean.
STUDY GUIDE WITH COMPLETE
SOLUTIONS
●● What is Moore's Law?
Answer: The capacity of ICs doubles roughly every 18 months
●● Which assigns the vector's last element with 99?
vector<int> myVector(15);
Answer: myVector.at(14)= 99;
●● Which reads an entire line of text into string myString?
Answer: getline(cin, myString);
●● What is written to the file, myfile.txt?
#include <iostream>
#include <fstream>
using namespace sld;
int main() {
,ofstream outFS;
string str;
cout << "Opening a fie" << endl;
outFS.open("myfile.tx");
if (outFS is_open()) {
cout << "Could not open fle myfile.txt." << endl;
return 1;
}
outFS << "This is test data" ;
outFS.close();
return 0;
}
Answer: This is test data
●● Which statement can be used instead of Statement 1?
clasa Sample {
public:
Sampie (int xValue = 0, int yValue = 0);
void ShowData();
};
int main () {
, Sample* sample1 = new Sample;
(*sample1).ShowData(); //Statement 1
Answer: (sample1) --> ShowData();
●● Which assigns the vector's first element with 99?
vector<int> myVector(4);
Answer: myVector.at(0) = 99;
●● Which XXX adds input values until a 0 is input?
int number;
int sum = 0;
do {
cin >> number;
sum= sum + number;
} while (XXX);
Answer: number ! = 0
●● If the input sets int x with 5 and int y with 7, what is the ending value
of z? z is declared as a boolean.