Strings
Vectors
Structs
Program Design
Random
100

How do you declare an empty string?

string name = "";

100

How do you declare a vector of strings?

vector<string> myVector;

100

What data types can structs contain?

Any/all

100

If you are repeating the same thing in your code multiple times, what should you do?

Create a function

100

What is the difference between an integer and a double?

integer is only whole numbers, double can contain decimals

200

Demonstrate 2 ways to declare a string named class and initialize it with the value "ENGR101"

string class = "ENGR101";

string class("ENGR101");

string class;
class = "ENGR101";

200

How do you clear a vector?

myVector.clear()

200

What should you do to the name of your struct when creating it?

Capitalize the first letter

200

Which function do you write the main part of your program in?

int main(){}

200

How do you declare a new filestream for the input file named "input.txt"?

ifstream file("input.txt");

300

How do you combine the following strings:
string a = "my";
string b = "name";
so that they read "my name"

string newString = a + " " + b;

300

How can you declare a vector of int's named numbers with the numbers 3,4,5,6 in one line?

vector<int> numbers{3, 4, 5, 6};

300

Create a struct Person with member variables name, age, and height

struct Person{
   string name;
   int age;
   double height;
};


300

If you know the number of times you are going to do something, which type of loop should you use?

for

300

What return type should you use for a function that has no return value?

void

400

string mail = "email";

Replace the letter e with g

mail.replace(0,1,"g");

400

How can you initialize a vector of size 4 containing the character 'a' using one line of code?

vector<char> myVector(4, 'a');

400

How do you access the first Planet struct in
vector<Planet> planets

400

What variable type does the .size() function produce? (ex. myVector.size())

size_t

400

Which code library do you need to include in order to use input/output filestreams? (use correct code syntax)

#include <fstream>

500

How do you print out only the o and k in the string:

string w = "working";

cout << w.at(1) << " " << w.at(3) << endl;

500

Write a for loop that would iterate through
vector<int> numbers
and print out each number. (your code shouldn't generate warnings)

for(size_t i = 0; i < numbers.size(); ++i){
    cout << numbers.at(i);
}

500

What is wrong with this code?

struct Per{
   string name;
};
int main(){
   Per pNew;
   cout << npew.name << endl;
}

The cout statement won't print anything since pNew is empty

500

How do you run a program after compiling it using this compile statement:
g++ -std=c++11 -Wall -pedantic myCode.cpp myFunctions.cpp -o myFuncCode

./myFuncCode

500

Write a function header for a function called calculator that takes in a string and a double and returns a double.

double calculator(string s, double x){}