Announcements and Reminders
|
Topics |
Terminology |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
C++ Program Basics What does int main() mean? Is return 0 required? Program 2-1 from the textbook cout What is cout?
What is the << operator? aka the insertion operator, the left-shift operator What is endl? endline, aka a manipulator What is a newline? aka \n Escape sequences (see Table 2-2) \n \t \a \r \\ \" Literals, variables and types Literals Types
int
double C-string, null terminated char array char Variables Identifiers Used for variables, constants, functions, user-defined types What are the rules for creating an identifier?
Types Primitive types or Built-In types
int
double char float long short long long long double unsigned, unsigned int unsigned long unsigned short unsigned char C-string, null terminated char array The string class
#include
<string>
A string variable or object How do you know the difference between a variable and an object? Input cin is used to enter data into a variable. More precisely, cin gets data from the input buffer and copies it into a memory location (a variable). cin uses the right-shift operator ( >> ). The right-shift operator is also called the extraction operator. Why?
What header file is needed to use cin? What is cin (type) ? Variables, int type, assignment operatorProgram 2-7 from the textbookInteger Types
How do you choose the right type?
Program 2-10 - page 46 char typechar C1 = 'A';
What does convert mean? What is a conversion? The string class
use of a string object (aka a string variable)string text;
text = "Have a nice day"; cout << text; Floating point types
Minimum and maximum floating point constant values are defined in <cfloat>. Floating point literals. What is the type of a floating point literal? Program 2-16 - Page 56 The bool typeThe bool type is a built-in, or primitive type.Variables
Arithmetic operators
operator precedence - Page 1289 integer division static_cast Program 2-21 - Page 65 CommentsProgram 2-26 - Page 72Program 2-27 - Page 72 Constantsliteralnamed defined Programming StyleProgram 2-29 - Page 75Program 2-30 - Page 76 How would you modify
this program to read the values of shares and avgPrice from the
keyboard?
Videos Understanding a Simple C++ Program More on Printing Text Variables Read Me |
comments preprocessor directive #include braces cout class object ostream operator left-shift operator insertion operator endl manipulator newline literal variable type primitive type built-in type int double char float long short long long long double unsigned, unsigned int unsigned long unsigned short unsigned char signed char unsigned long long C-string string class object header file <string> floating point type float double long double bool type identifier underscore case sensitive cin istream Operators sizeof assignment comma arithmetic + - * / % mod binary unary operator precedence static_cast comments c++ style comment c style comment literal constant named constant defined constant const #define |