COSC-051 Lecture Notes - Lecture 4: String Literal, Integer Literal, January 30

76 views3 pages

Document Summary

Variables of the same type can be defined a) b) in separate statements int length; int width; in the same statement int length, width; Variables of different types must be defined in separate statements. Available in different sizes (i. e. , number of bytes): int, long int, and long long int. Ex: short int x; int y; long long z; C++ allocates one bit for the sign of the number. The rest of the bits are for data. If your program will never need negative numbers, declare variables to be unsigned. All bits in unsigned numbers are used for data. A variable is signed unless the unsigned keyword is used at variable definition. Int can be omitted from a variable definition except an int itself. Ex: short temperatures; unsigned short booksonorder; unsigned long long magnitude; int grades; To store an integer literal in a long memory location, put l" at the end of the number: long rooms =

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents