CMPSCI 121 Flashcards
Ch1 - Both main memory and secondary storage are types of memory. Describe the difference between the two.
Main memory, or RAM, is volatile, which means its contents are erased when power is removed from the computer. Secondary memory, such as a disk, does not lose its contents when power is removed from the computer.
Ch1- What is the difference between system software and application software?
An OPERATING SYSTEM is a set of programs that manages the computer’s hardware devices and controls their processes. Application software consists of programs that users use to solve specific problems or perform general operations.
Ch1- What type of software controls the internal operations of the computers hardware?
An operating system
Ch1- Why must program written in a high-level language be translated into machine language before they can be run?
Because the computer only processes machine language instructions.
Ch1- Why is it easier to write a program in a high-level language than in machine language?
Because high level languages are more like natural language.
h1- Explain the difference between an object file and an executable file?
An object file contains machine language instructions, but it does not contain code for any library routines that may be necessary. An executable file is a program, ready to run. It contains the machine language code translated from the programmer’s source file, as well as the code for any necessary library routines.
Ch1- What is the difference between a syntax error and a logical error?
A syntax error is the misuse of a key word, operator, punctuation, or other part of the programming language. A logical error is a mistake that causes the program to produce the wrong results.
Ch1- Computers can do many different jobs because they can be _____
programmed
Ch1- The job of the ______ is to fetch instructions, carry out the operations commanded by the instructions, and produce some outcome or resultant information.
CPU
Ch1- Internally, the CPU consists of the _____ and the ______
Arithmetic Logic Unit and Control Unit
Ch1- A(n) _____ is an example of a secondary storage device.
disk
Ch1- The two general categories of software are _____ and_____
Operating Systems and Application Software
Ch1- A program is a set of _____
instructions
Ch1- Since computers can’t be programmed in natural human language, algorithms must be written in a(n)_____ language.
programming language
Ch1- ________ is the only language computers really process>
machine language
Ch1- ______ languages are close to the level of humans in terms of vocabulary
high-level
Ch1- ______ languages are close to the level of the computer
Low-level
Ch1- A program’s ability to run on several different types of computer systems is called_____
portability
Ch1- Words that have special meaning in a programming language are called
Key Words
Ch1- Words or names defined by the programmer called
programmer-defined symbols
Ch1- _____ are characters or symbols that perform operations on one or more operands
operators
Ch1- _____ characters or symbols mark the beginning or end of programming statements, or separate items in a lint
punctuation
Ch1- The rules that must be followed when constructing a program are called ____
syntax
Ch1- A(n) ____ is named storage location
variable
Ch1- A variable must be ____ before it can be used in a program
defined
Ch1- The three primary activities of a program _____, ____, and _____.
input, processing, output
Ch1- _____ is information a program gather from the outside world
input
Ch1- _____ is information a program sends to the outside world
output
Ch1- A(n) ____ is a diagram that graphically illustrates the structure of a program
Hierarchy Chart
Ch2- How many operands does each of the following types of operators require?
1 unary
2 binary
3 Ternary
Ch2- How may the double variables temp, weight, and age be defined in one statement?
double temp, weight, age;
Ch2- How may the int variables months, days, and years be defined in one statement, with months initialized to 2 and years initialized to 3?
int months = 2, days, years = 3;
Ch2- Write assignment statements that perform the following operations with the variables a, b, and c;
A) Adds 2 to a and stores the result in b
B) Multiples b by 4 and stores the result in a
C) Divides a by 3.14 and stores the result in b
D) Subtracts 8 from b and stores the result in a
E) Stores the value 27 in a
F) Stores the character ‘K’ in c
G) Stores the ASC2 code for ‘B’ in c
A)b = a + 2; B)a = b * 4; C)b = a / 3.14; D)a = b - 8; E)a = 27; F)c = 'K'; G)c = 66;
Ch2- Is the following comment written using single-line or multi-line comment symbols? */ This program was written by M. A, Codewriter*/
Multi-single line
Ch2- Is the following comment written using single line or multi line comment symbols // This program was written by M. A Codewriter
Single Line
include
Ch2- Modify the following program so it prints two blank lines between each line of text
using namespace std;
int main ()
{
cout «_space;” Two mandolins like creatures in the”;
cout «_space;“dark”;
cout «_space;” Creating the agony of ecstasy.”;
cout «_space;” - George Barker”;
return 0;
}
#include int main() { cout << "Two mandolins like creatures in the\n\n\n"; cout << "dark\n\n\n"; cout << "Creating the agony of ecstasy.\n\n\n"; cout << " - George Barker\n\n\n"; return 0; }
Ch2- What will the following programs print out the screen?
A) #include
using namespace std;
int main () { int x = 0, y = 2; x = y * 4; cout << x << endl << y << endl; return 0; }
C) #include
using namespace std;
int main () { cout << " I am the incredible"; cout << "computing\nmachine" ; cout << "\nand I will \namaze\n"; cout << "you."; return 0; }
D) #include
using namespace std;
int main () { cout << " Be careful\n"; cout << " This might /n be a trick"; return 0; }
E) #include
using namespace std;
int main () { int a, x = 23; a = x % 2; cout << x << endl << a << endl; return 0; }
A) 0
100
B) 8
2
C) I am the incrediblecomputing machine and I will amaze you.
D) Be careful
This might/n be a trick question
E) 23
1
Ch2- Every complete statement ends with a(n) _____
A) Period
B) #symbol
C) semicolon
D) ending brace
C
Ch2- Which of the following statements is correct A) #include (iostream) B) #include (iostream} C) #include D) # include {iostream} E) All of the above
C
Ch2- Every C++ Program must have a _____
function main
Ch2- Preprocessor directors begin with
#