Show Menu
Cheatography

Programming Fundamentals I Cheat Sheet by

COSC, PRGR

CH 1

The basic commands that a computer performs are input (get data), output (display result), storage, and perfor­mance of arithmetic and logical operat­ions.
T
Main memory is directly connected to the CPU.
T
When the computer is turned off, everything in secondary memory is lost.
F
The devices that feed data and programs into computers are called output devices.
F
Inform­ation stored in main memory must be transf­erred to some other device for permanent storage.
T
The device that stores inform­ation perman­ently (unless the device becomes unusable or you change the inform­ation by rewriting it) is called primary storage.
F
The command that does the linking on Visual C++ 2012 Express and Visual Studio 2012 is Make or Remake.
F
When you compile your program, the compiler identifies the logic errors and suggests how to correct them.
F
To develop a program to solve a problem, you start by analyzing the problem.
T
C++ programs have always been portable from one compiler to another.
F
Several categories of computers exist, such as ____.
mainframe, midsize, and micro
The basic commands that a computer performs are ____, and perfor­mance of arithmetic and logical operat­ions.
input, output, storage
Main memory is called ____.
random access memoryq
The ____ is the brain of the computer and the single most expensive piece of hardware in your personal computer.
CPU
Main memory is an ordered sequence of items, called ____.
memory cells
The devices that feed data and programs into computers are called ____ devices.
input
The devices that the computer uses to display results are called ____ devices.
output
____ programs perform a specific task.
Applic­ation
The ____ monitors the overall activity of the computer and provides services.
operating system
____ represent inform­ation with a sequence of 0s and 1s.
Digital Signals
A sequence of eight bits is called a ____.
byte
The digit 0 or 1 is called a binary digit, or ____.
bit
The term GB refers to ___
gigabyte
____ consists of 65,536 charac­ters.
Unicode
A program called a(n) ____ translates instru­ctions written in high-level languages into machine code.
compiler
A program called a(n) ____ combines the object program with the programs from libraries.
linker
A program that loads an executable program into main memory is called a(n) ____.
loader
A step-b­y-step proble­m-s­olving process in which a solution is arrived at in a finite amount of time is called a(n) ____.
algorithim
Dividing a problem into smaller subpro­blems is called ____ design.
structured
A(n) ____ consists of data and the operations on those data.
object
The progra­mming language C++ evolved from ____.
C
 

CH 2.

The memory allocated for a float value is ____ bytes.
four
In C++, reserved words are the same as predefined identi­fiers.
F
The maximum number of signif­icant digits in values of the double type is 15.
T
The maximum number of signif­icant digits in float values is up to 6 or 7.
T
An operator that has only one operand is called a unique operator.
F
If a C++ arithmetic expression has no parent­heses, operators are evaluated from left to right.
T
A mixed arithmetic expression contains all operands of the same type.
F
Suppose a = 5. After the execution of the statement ++a; the value of a is 6.
T
The escape sequence \r moves the insertion point to the beginning of the next line.
F
A comma is also called a statement termin­ator.
F
Suppose that sum is an int variable. The statement sum += 7; is equivalent to the statement sum = sum + 7;
T
The ____ rules of a progra­mming language tell you which statements are legal, or accepted by the progra­mming language.
Syntax
Which of the following is a reserved word in C++?
char
Which of the following is a legal identi­fier?
program_1
____ is a valid int value.
46259
____ is a valid char value.
'A'
An example of a floating point data type is ____
double
(2X) The value of the expression 33/10, assuming both values are integral data types, is ____. // The value of the expression 17 % 7 is ____.
3
The expression static­_ca­st(9.9) evaluates to ____
9
The expression static­_ca­st(6.9) + static­_ca­st(7.9) evaluates to ____.
13
The length of the string "­com­puter scienc­e" is ____. Question 22 options:
16
In a C++ program, one and two are double variables and input values are 10.5 and 30.6. After the statement cin >> one >> two; executes, ____.
one = 10.5, two = 30.6
Suppose that count is an int variable and count = 1. After the statement count++; executes, the value of count is ____.
2
Choose the output of the following C++ statement: cout << "­Sunny " << '\n' << "Day " << endl;
Sunny Day
Which of the following is the newline character?
\n
____ are executable statements that inform the user what to do.
prompt lines
The declar­ation int a, b, c; is equivalent to which of the following?
int a,b,c;
Suppose that alpha and beta are int variables and alpha = 5 and beta = 10. After the statement alpha *= beta; executes, ____.
alpha = 50
Suppose that sum and num are int variables and sum = 5 and num = 10. After the statement sum += num executes, ____.
sum = 15
Insertion Point 1
alpha = beta; beta = beta + 1;
 

CH 3

It is a good idea to redefine cin and cout in your programs
F
In the statement cin >> x; , x can be a variable or an expression
F
The following statements will result in input failure if the input values are not on a separate line. (Assume that x and y are int variab­les.) cin >> x; cin >> y;
F
The number of input data extracted by cin and >> depends on the number of variables appearing in the cin statement.
T
The extraction operator >> skips only all leading blanks when searching for the next data in the input stream.
F
When reading data into a char variable, after skipping any leading whitespace charac­ters, the extraction operator >> finds and stores only the next character; reading stops after a single character.
T
Entering a char value into an int variable causes serious errors, called input failure.
T
If input failure occurs in a C++ program, the program terminates immedi­ately and displays an error message.
F
In an output statement, each occurrence of endl advances the cursor to the end of the current line on an output device.
F
You can use the function getline to read a string containing blanks
T
Suppose that x is an int variable and y is a double variable and the input is: 10 20.7 Choose the values after the following statement executes: cin >> x >> y;.
x = 10, y = 20.7
Suppose that x and y are int variables. Which of the following is a valid input statement?
cin >> x >> y;
Suppose that x is an int variable, y is a double variable and ch is a char variable and the input is: 15A 73.2 Choose the values after the following statement executes: cin >> x >> ch >> y;
x = 15, ch = 'A', y = 73.2
Suppose that x is an int variable, ch is a char variable, and the input is: 276.
B ch = '2', x = 76
Suppose that alpha is an int variable and ch is a char variable and the input is: 17A What are the values after the following statements execute? cin » alpha; cin » ch;
alpha = 17, ch = 'A'
Suppose that x is an int variable, y is a double variable, z is an int variable, and the input is: 15 76.3 14 Choose the values after the following statement executes: cin >> x >> y >> z;
x = 15, Y = 76 . 3 , z = 14
Suppose that ch1, ch2, and ch3 are variables of the type char and the input is: A B C Choose the value of ch3 after the following statement executes: cin >> ch1 >> ch2 >> ch3;
'C'
Suppose that x and y are int variables, z is a double variable, and the input is: 28 32.6 12
x = 28, Y = 32, z = 0.6
Suppose that x and y are int variables, ch is a char variable, and the input is: 4 2 A 12 Choose the values of x, y, and ch after the following statement executes: cin >> x >> ch >> y;
This statement results in input failure
Suppose that ch1 and ch2 are char variables, alpha is an int variable, and the input is: A 18 What are the values after the following statement executes? cin.ge­t(ch1); cin.ge­t(ch2); cin >> alpha;
ch1 = 'A', ch2 = , " alpha = 18
Suppose that ch1, ch2, and ch3 are variables of the type char and the input is: A B C What is the value of ch3 after the following statements execute? cin.ge­t(ch1); cin.ge­t(ch2); cin.ge­t(ch3);
'B'
When you want to process only partial data, you can use the stream function ____ to discard a portion of the inp
ignore
Suppose that alpha, beta, and gamma are int variables and the input is: 100 110 120 200 210 220 300 310 320 What is the value of gamma after the following statements execute? cin >> alpha; cin.ig­nor­e(100, '\n'); cin >> beta; cin.ig­nor­e(1­00,­'\n'); cin >> gamma;
300
Suppose that ch1 and ch2 are char variables and the input is: WXYZ What is the value of ch2 after the following statements execute? cin.ge­t(ch1); cin.pu­tba­ck(­ch1); cin >> ch2;
W
Suppose that ch1 and ch2 are char variables and the input is: WXYZ What is the value of ch2 after the following statements execute? cin >> ch1; ch2 = cin.pe­ek(); cin >> ch2;
X
In C++, the dot is an operator called the ____ operator.
member access
Suppose that x = 25.67, y = 356.876, and z = 7623.9674. What is the output of the following statem­ents? cout << fixed << showpoint; cout << setpre­cis­ion(2); cout << x << ' ' << y << ' ' << z << endl;
25.67 356.88 7623.97
x = 55.68, y = 476.859, and z = 23.8216. statem­ents? cout << fixed << showpoint; cout << setpre­cis­ion(3); cout << x << ' ' << y << ' ' << setpre­cis­ion(2) << z << endl;
55.680 476.860 23.82
Suppose that x = 1565.683, y = 85.78, and z = 123.982. What is the output of the following statem­ents? cout << fixed << showpoint; cout << setpre­cis­ion(3) << x << ' '; cout << setpre­cis­ion(4) << y << ' ' << setpre­cis­ion(2) << z << endl;
1565.683 85.7800 123.98
What is the output of the following statem­ents? cout << setfil­l('*'); cout << "­123­456­789­012­345­678­90" << endl cout << setw(5) << "­18" << setw(7) << "­Hap­py" << setw(8) << "­Sle­epy­" << endl
123456­789­012­345­67890 18Happy*Sleepy
What is the output of the following statem­ents? cout << "­123­456­789­012­345­678­901­234­567­890­" << endl cout << setfil­l('#') << setw(10) << "­Mic­key­" << setfill(' ') << setw(10) << "­Don­ald­" << setfil­l('*') << setw(10) << "­Goo­fy" << endl;
123456­789­012­345­678­901­234­567890 ####Mickey Donald*Goofy
____ is a parame­terized stream manipu­lator.
setfill
Manipu­lators without parameters are part of the ____ header file.
iostream
Consider the following program segment. ifstream inFile; //Line 1 int x, y; //Line 2 ... //Line 3 inFile >> x >> y; //Line 4 Which of the following statements at Line 3 can be used to open the file progda­ta.dat and input data from this file into x and y at Line 4?
inFile.op­en(­"­pro­gda­ta.d­at­");
Suppose that outFile is an ofstream variable and output is to be stored in the file output­Dat­a.out. Which of the following statements opens the file output­Dat­a.out and associates outFile to the output file?
outFil­e.o­pen­("ou­tpu­tDa­ta.o­ut­");
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.