




















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An overview of memory concepts, variable names, data types, and operators in C++. It includes a table of data types with their corresponding sizes and ranges of values. The document also covers the const modifier, arithmetic operators, decision making with equality and relational operators, and confusing equality and assignment operators. It concludes with a discussion of C++ expressions and mixed type expressions. useful for students studying introductory programming in C++.
Typology: Slides
1 / 28
This page cannot be seen from the preview
Don't miss anything!





















Memory Concepts
Fundamental Data Types
Type Name Bytes Other Names Range of Values int 4 signed – 2,147,483,648 to 2,147,483, unsigned int 4 unsigned 0 to 4,294,967, bool 1 none false or true char 1 none – 128 to 127 signed char 1 none – 128 to 127 unsigned char 1 none 0 to 255 short 2 short int, signed short int – 32,768 to 32, unsigned short 2 unsigned short int 0 to 65, long 4 long int, signed long int – 2,147,483,648 to 2,147,483, unsigned long 4 unsigned long int 0 to 4,294,967, long long 8 none – 9,223,372,036,854,775,808 to 9,223,372,036,854,775, unsigned long long 8 none 0 to 18,446,744,073,709,551, float 4 none +/-3.4E +/- 38 double 8 none +/-1.7E +/- 308 long double same as double none same as double
What if you try to change a const?
Arithmetic Operators
Arithmetic Operators
Decision Making: Equality and Relational Operators Standard algebraic equality operator or relational operator C++ equality or relational operator Example of C++ condition Meaning of C++ condition Relational operators
> x > y x is greater than^ y < < x < y x is less than y >=^ x >= y^ x^ is greater than or equal to^ y <=^ x <= y^ x^ is less than or equal to^ y Equality operators = == x == y x is equal to^ y !=^ x != y^ x^ is not equal to^ y
Precedence and Associativity
26 if ( num1 < num2 ) 27 cout << num1 << " is less than " << num2 << endl; 28 29 if ( num1 > num2 ) 30 cout << num1 << " is greater than " << num2 << endl; 31 32 if ( num1 <= num2 ) 33 cout << num1 << " is less than or equal to " 34 << num2 << endl; 35 36 if ( num1 >= num2 ) 37 cout << num1 << " is greater than or equal to " 38 << num2 << endl; 39 40 return 0 ; // indicate that program ended successfully 41 42 } // end function main Enter two integers, and I will tell you the relationships they satisfy: 22 12 22 is not equal to 12 22 is greater than 12 22 is greater than or equal to 12