Questions and Answers
How to cin everything (including spaces)?
getline(cin, stringVar)
What is the cout operator?
What is the range of int variables?
+/- 2 billion (2,000,000,000)
How to initialize a constant?
Signup and view all the answers
Is 'doubleVar = 36 * intVar' an int or double?
Signup and view all the answers
What is ==?
Signup and view all the answers
What is =?
Signup and view all the answers
What is a function declaration?
Signup and view all the answers
What is a function definition?
Signup and view all the answers
What is ASCII order?
Signup and view all the answers
How to compare floating point numbers?
Signup and view all the answers
What is the order operators evaluated?
Signup and view all the answers
Study Notes
Input and Output in C++
- Use
getline(cin, stringVar)
to read input from the user that includes spaces.
Output Operator
- The
cout
operator is represented by the symbol>
for outputting text and values to the console.
Integer Range
- The range of
int
variables spans approximately ±2 billion, specifically from -2,147,483,648 to 2,147,483,647.
Constant Initialization
- A constant variable is initialized using the identifier format
CONST_VAR
.
Variable Type Evaluation
- When evaluating the expression
doubleVar = 36 * intVar
, the resulting type is anint
but may be displayed as adouble
with decimal points (e.g., 36.00).
Equality Operator
- The
==
operator is used to check if two values are equal.
Assignment Operator
- The
=
operator serves as the assignment operator, used to assign values to variables.
Function Declaration
- A function declaration follows the format:
return type function name (parameter list);
indicating its return type, name, and parameters.
Function Definition
- A function definition is structured as:
return type function name(parameter list) { code of function }
, containing the implementation details.
ASCII Order
- In ASCII, characters are ordered from
0-9
, followed byA-Z
, and thena-z
, indicative of numerical and alphabetical sorting.
Comparing Floating Point Numbers
- For comparing floating point values, avoid using
==
or!=
. Instead, usefabs(x - y) < 0.0001
to check for equality andfabs(x - y) > 0.0001
to check for inequality.
Operator Precedence
- The order of operators evaluated in expressions follows this hierarchy: parentheses
( )
, logical NOT!
, arithmetic operations, and then relational operators like>
.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
Test your knowledge on the basics of C++ programming with these flashcards from EECS 183. Each card covers fundamental concepts such as input/output streams, data types, and variable initialization. Perfect for preparing for Exam 1!