ANOTHER MIXED BAG OF C++ QUESTIONS

Home

getline(cin, destination) reads all the characters including whitespace from the input stream, stores them (including whitespace!) in destination, then does what?

Discards the endline character, ie. getline removes it but doesn’t store it.

Global variables are bad style because they greatly increase the risk of -----

Global constants are good style because -----

side effects; no side effects can result from a global constant because its value can't be changed by any program statement.
How to create the message "I'm not a storage place, I just point to another variable"?

Use &. In tracing your program, you draw an arrow upwards to the variable that it points to and write the value at the top end of the arrow.

How to do it if you want to calculate and return more than 1 value?

Either 2 functions, or make the datatype void and return the value as parameters.

if expression statement1 else statement2 – Insert punctuation where it belongs.

if (expression) {statement1;} else {statement2;}

Note: all the brackets are optional, unless there are compound (= multi-line) statements.

If your program contains many user-defined functions, in what order will you list them in?

Alphabetic by function name in both declarations and definitions sections would be good style.

If your tables are outputting weird numbers, what to do?

One possible cause: you've mucked up your numbers of rows and columns.

ifstream ifstreamName;

ifstreamName.open (fileName);

Which of these 2 lines establishes an actual connection between the program and the file?

Line 1 declares this as an uninitialised fstream, ie. it establishes a potential connection.

Line 2 establishes the actual connection between the program and the file called fileName.

In a nested if statement, an else if matched with -----

the nearest preceding unmatched if.
In type name[size], size must be a ----- (clue: 2 words)

  -----

const int.
It's important to spell parameter names accurately (ie, the same as in their calling function) because value parameters are matched by name.

Agree?

Hope not, because value parameters are matched by position. Two variables with the same name will have 2 different memory spaces.

Lambda calculus consists of only ----- it has no ----- "lambda abstractions" (=functions) and variables.

No constants, no numbers, no maths functions – all entities are represented as functions.

Linux:

The command pwd does what?

your Present Working Directory.
Loops are entered when the test outcome is ----- and bypassed when they test as ----- and exited when they test as -----

True à enters the loop.

False will bypass or exit.

Modulus is executed (before / after) division.

After.

Home |


setstats 1