Shared Flashcard Set

Details

Chapter 2: C++ basics
variables and assignments, input and output, data types and expressions, simple flow of control, program style
13
Computer Science
Undergraduate 1
04/12/2012

Additional Computer Science Flashcards

 


 

Cards

Term
What is an identifier?
Definition
An identifier is the name of a variable (or other item). It must start with either a letter or an underscore. The following must be letters, digits or underscores.
Term
What does it mean to declare a variable?
Definition

When you declare a variable you are telling the compiler what kind of data you will be storing in the variable.

i.e. int, double

Term
Where do you declare variables?
Definition
Either just before it is used or at the start of the main part of your program.
Term
What is the problem with an uninitialized value?
Definition
This is a variable that has not been given a value.  Once ran the variable will be filled with a 'garbage value'.
Term
What is the three lines with will set a decimal to 2 places?
Definition

cout.setf(ios::fixed);

cout.setf(ios::showpoint);

cout.precision(2);

Term
What is a double?
Definition
A double is a variable storage with decimal places, up to 14 places of accuracy.
Term
What is the memory used and precision of each of the following: short, int, long, float, double, and long double?
Definition

A short uses 2 bytes.

An int uses 4 bytes.

A long uses 4 bytes.

A float uses 4 bytes and has 7 digits of precision.

A double uses 8 bytes and has 15 digits.

A long double uses 10 bytes and has 10 digits.

Term
What are boolean expressions?
Definition
Boolean expressions evaluate to one or the two values, true or false.
Term
What is the precedence of operators?
Definition
++ or --, ( ), static_cast, * or /, %,  + or -
Term
What is flow of control?
Definition

Flow of control is the order in which statements are executed.

i.e. branching and looping

Term
What is an if-else statement and when is it used?
Definition

An if-else statement is used if there are two options needed for the program.

Ex. IF this is true, do this,

ELSE, do this.

Code: if (x>0)

y=x + 9;

else

y=x;

Term
What is a boolean expression?
Definition

A boolean expression is any expression that is either true or false. An if-else statement always contains a boolean expression. It uses ==, !=, <= or >=. It also uses && (combined if, both must be true) and || (or).

 

Term
What is a compound statement?
Definition

A compound statement is a list of statements enclosed in a pair of braces. A compound statement is treated as one single statement by C++.

code: if (x>0)

{cout << "blah blah";

y=x+9; }

Supporting users have an ad free experience!