Looks like no one added any tags here yet for you.
Which mode in Vim allows you to write new code?
insert
What is the relationship between Unix and Linux?
Linux is based on Unix.
Explain the significance of Vim in the context of coding in a command line interface.
To write any code, you need a code editor, such as VSCode, but editors such as VSCode cannot be used in a command line interface. So, Vim is significant because it's what allows the user to be able to write code in a command line interface.
To make a new directory using the command line, you would use which command?
mkdir
What are normal mode and insert mode in Vim and how do you switch between them?
Normal mode allows you to navigate code files and execute certain commands, whereas insert mode only allows you to edit and add new code. Use i to access insert mode and esc to go back to normal mode.
Explain every part of both the command and the command line prompt below. (samsmith, the @ symbol, etc)
samsmith@workstation2:~$ cd Music
samsmith is the user, @ separates the user and the computer, workstation2 is the computer samsmith is connected to, : separates the computer and the current directory, ~ is the home directory, $ serves as a separator between the directory and the area for the user to execute commands, and cd Music is used to move the user into the Music folder.
To remove a directory using the command line, you would use which command?
rmdir
What is the difference between a graphical user interface (GUI) and a command line interface (CLI)?
A GUI allows for users to access and run commands simply by clicking buttons or pictures, for instance, on windows you can access your documents folder by clicking on the file explorer icon and clicking on the documents folder. On a CLI, there are no images or buttons to click and you must manually type in commands to access certain files or programs, for instance, you would have to type cd Documents to access your documents folder.
What is an operating system?
The underlying program controlling the basic functionality of the computer.
What command is used to copy a line in Vim?
yy
How do you use a command such as copy or delete across multiple lines in vim?
You put the number first, then the command (Ex. 4yy for copy four lines).
What is Unix?
Unix is an operating system that linux is based off of.
What is the command line interface in Linux?
A way to navigate the operating system using commands.
How do you list the contents of a directory using the command line?
ls
What is the difference between an absolute path and a relative path?
An absolute path starts from the root directory, while a relative path starts from the current directory.
Which operating system is the Macintosh operating system (MacOS) based on?
linux
How do you write and quit Vim?
In normal mode, type :wq
What happens if cin is used to read an integer, but the user types a double?
The cin call fails and goes into a fail state.
How can you revive cin from a fail state?
Use cin.clear().
How can you check if cin failed to read the correct data type?
Use cin.fail().
What does cin.ignore() do?
Skip one or more character in the key buffer
cin.ignore(n, c);
cin.ignore(20, '\n'); //Skip next 20 characters or until \n
cin.ignore(); //Skip only next character
Also allows you to move past bad input when you use cin.clear() and cin.ignore(numeric_limits
What does cin.get() allow you to do?
Read and save a single character from input, including whitespace.
Which manipulator is used to set the width of the NEXT FIELD ONLY??!?!?
setw()
What manipulator is used to change the character used to fill extra spaces in a field?
setfill() - must be a char in single quotes (ex. '0')
Which manipulator is used to determine whether the plus sign (+) is shown with positive numbers?
showpos
What does the setprecision(x) manipulator do?
Changes the float point precision. (Rounds to x decimal places)
WHICH MANIPULATOR IS NOT PERSISTENT????!?!?!?!?
setw()
How do you paste copied lines in vim?
p
How do you delete a line in vim?
dd
How do you remove a file in the command line?
rm
How do you remove a directory in the command line?
rmdir (directory must be empty)
How do you copy a file in the command line?
cp (file) (new destination)
What command do you use to remote connect to a hydra/tesla machine?
ssh (secure shell)
How do you copy a file from a hydra/tesla machine to your personal computer using the command line?
scp (netid@computername.eecs.utk.edu):(directory of file on hydra/tesla) (where you want to copy the file to)
What does whoami do?
It displays your user name
How do you clear the console logs in the command line?
clear
How do you move a file in the command line?
mv (path of file) (path of destination)
How do you move to the parent directory in the command line?
cd ..
What do you need to #include for cin and cout?
<iostream>
What does wrapping cin in an if statement do?
It checks to make sure that the value types are the same (ex. if x is an int and you have if(cin>>x), cin>>x will return true if x is an int and false if it is not.)
If you use I/O manipulators, what must you #include?
<iomanip>
How do you right or left justify using I/O manipulators?
right for right justify, left for left justify.
If you want to use setprecision, what must also be included so the number is not printed in scientific notation?
fixed
What does the showpoint manipulator do?
writes a decimal point for a double output, even if the point is unnecessary.
How do you use manipulators to notate scientific notation?
scientific
What does the hex manipulator do?
converts the output to hex format.
What are vectors in c++ similar to in java?
arrayLists
What do you need to #include if you want to use vectors?
<vector>
How do you declare a vector in c++?
vector<(data type)> vectorName;
How can you access a vector element at a selected index in c++?
vectorName[i] or vectorName.at(i)
What index do vectors start at?
ZERO!!!!
How can you add a new element to the end of a vector in c++?
vectorName.push_back()
How can you get the size of a vector in c++?
vectorName.size()
How do you clear a vector?
vectorName.clear()
How do you resize a vector?
vectorName.resize()
How can you declare a 2D vector?
vector<vector<(data type)>> vectorName
How can you access a single element in a 2D vector?
vectorName [row][column]
What are file streams?
They allow you to read input and print output in external files.
What do you need to #include to use filestreams?
<fstream>
How do you declare a file stream input name and open a file?
ifstream fin;
fin.open("input.txt"); // THIS MUST BE IN DOUBLE QUOTES OR BE A STRING VARIABLE
OR
ifstream fin("input.txt");
What do you need to put after you are done collecting input with fin?
fin.close();
How do you declare a file stream output name and open a file?
ofstream fout;
fout.open("output.txt"); // THIS MUST BE IN DOUBLE QUOTES OR BE A STRING VARIABLE
OR
ofstream fout("output.txt");
What is stored in var1 when this line of code is excecuted if input.txt contains "John Doe"
ifstream fin("input.txt");
string var1;
fin >> var1;
fin.close();
John
Once you are done using fout, what line do you have to put?
fout.close()
Can you use IO manipulators for fout?
yes
What are the two ways you can check if an fin or fout file was successfully opened?
.is_open() or .fail()
How can you get an entire line in c++?
getline(input stream you want to use (ex. cin, fin, sin), string to store in, OPTIONAL; delimiter(char to stop at, \n by default))
What do you need to #include to use getline?
<string>
If you get an number from getline(), what must you use to store it as an int?
stoi()
What does it mean if you wrap fin or getline inside of a while loop?
It goes through each line in the input stream.
If you want to use argv and argc, what do you write instead of int main?
int main(int argc, char **argv){}
OR
int main(int argc, char *argv[]){}
What does argc return?
The number of arguments used when the program is run using ./
What will argc return in this scenario?
./calculate 5 4 3 10
5
What is argv and what does it return?
argv means argument values, and argv[i] will return the argument at that index (arguments are separated by whitespace).
What will argv[0] always return?
The name of the program.
What will argv[2] return in this scenario?
./calculate 17 23 4
23
How can you error check with argc?
If you know the number of arguments needed, you can use an if statement to check if argc is not equal to your specified number of arguments.
What must you #include if you want to use string streams?
<sstream>
How do you declare an input string stream object and an input string?
istringstream sin;
sin.str(variable);
OR
istringstreamsin(input);
How do you declare an output string stream object?
ostringstream sout;
How would you add an existing variable var1 to a string named myString using string streams?
sout << var1;
string myString = sout.str();
What does .str() contain when using stringstreams in c++?
With sin.str(), it sets the input string.
With sout.str(), it contains everything that has been added to the stringstream using sout.
What does sin/sout .clear() do?
Clears the string stream
If there is a vector v, do v.clear() and v.resize(0) both set the size of the vector to zero?
YEA!!!
When you use command line arguments, what data type is a single argument stored as?
A C-style string
Which justification (left/right) is default when using IO manipulators?
right
What does this line of code do?
vector
Creates a vector of 5 integers all initialized to zero.
How would you create a vector named myVector with three ints, 10, 20 and 30, in that order?
vector