CPSC 111

Lab Quiz 1

 

For the following questions, assume that UNIX refers to the UNIX version we use in our labs.

 

  1. How do you show the directory contents in UNIX?

 

  1. 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?

 

  1. What is the syntax to copy the file abc.txt to the directory above it?  How do you rename abc.txt to dce.txt?

 

  1. How do you remove abc.txt from the current directory?  How do you remove the directory my_dir?

 

  1. How does one print abc.txt to the printer my_printer from UNIX?

 

  1. What do the . and .. stand for in each directory?

 

  1. Why have we included the file iostream in each of our programs (Be specific as possible.)?

 

  1. 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;

 

  1. Where does standard output usually go?

 

  1. 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>

 

  1. Every standard header file declares its identifiers where (Be specific as possible)?

 

  1. How does one declare PI as a constant (PI = 3.14159)?

 

  1. In the following line, explain the purpose of each part:

 

g++  -o  abc  myfile.cpp

 

  1.   Explain the difference between the following two operators: "=" and "==".

 

  1. 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?