CPSC 111
Lab Quiz 1
For the following questions, assume that UNIX refers to the UNIX version we use in our labs.
- How do
you show the directory contents in UNIX?
- How do
you make a directory called my_dir in UNIX? After creating my_dir, how do you change to the newly
created directory my_dir?
- What
is the syntax to copy the file abc.txt to the directory above it? How do you rename abc.txt to dce.txt?
- How do
you remove abc.txt from the current directory? How do you remove the directory my_dir?
- How
does one print abc.txt to the printer my_printer from UNIX?
- What
do the .
and ..
stand for in each directory?
- Why
have we included the file iostream in each of our programs (Be specific as
possible.)?
- What is
the output of the following (Assume both variables have been declared):
...
a = 5;
b = 2;
if ((a % b) > 5) {
a = a + b;
b = a * b / (a – b);
}
else {
a = (5 – b) * a;
b = (b – a) * 2;
}
cout << "a: " <<
a << endl;
cout << "b: " <<
b << endl;
cout << "*"
<< "**" << endl;
- Where
does standard output usually go?
- The
following line is processed by the _________ (not compiler)? Also, what do the symbols < and >
indicate in the statement below?
This statement is called a _________ directive.
#include <iostream>
- Every
standard header file declares its identifiers where (Be specific as
possible)?
- How
does one declare PI as a constant (PI = 3.14159)?
- In the
following line, explain the purpose of each part:
g++ -o abc myfile.cpp
- Explain the difference between the
following two operators: "=" and "==".
- Write
a short program to ask the user for an integer. Then output the integer.
The output should not all be on the same line.
Extra Credit (No partial credit
given per question. You either get the
question, or you don't.):
1. Provide a brief description of the difference between syntax and semantics.
2. What data type would you use to store the following literal:
"Hello
world."
3. What does the ALU do in a computer?
4.
What symbols are used for the logical AND and OR (label your answers),
and in what type of expression are they used?
What term describes when the compiler
evaluates an expression with the logical AND, and does not evaluate the second
part of the expression?