CSC 1100 Lecture Notes - Lecture 4: String Literal, Ieee Floating Point
1 of 4
CSC 1100 – Problem Solving and Programming
Session 4 Notes – 17 January 2019
Administrative
Today’s session
Chapter 2 (continued)
– Variables
– Data types
– String and character literals
– Variable declarations
– Reserved words
Session Topics
Variables
● A variable is a named spot in memory used to hold a value.
● A variable has at least three characteristics:
✓ Name
✓ Data type
✓ Value
● A variable name:
✓ Begins with a letter or underscore.
✓ Is followed by zero or more letters, digits, and underscores.
Data types
● Every variable has a data type. This is so that humans and the computer know
how to handle and interpret it.
● Every programming language provides a set of data types.
● See C++ language specification on Canvas for the list of data types.
● A variable of data type char, short, int, long, or long long stores an integer.
● A variable of data type float, double, or long double stores a real number.
● See Data types sample application on Canvas.
Integer data types
● Each integer data type has a capacity: a minimum and maximum possible value.
● While an application is running, if the minimum possible value is exceeded (an
underflow) or the maximum possible value is exceeded (an overflow), the variable
value wraps around.
find more resources at oneclass.com
find more resources at oneclass.com
Document Summary
Is followed by zero or more letters, digits, and underscores. A variable is a named spot in memory used to hold a value. A variable has at least three characteristics: This is so that humans and the computer know how to handle and interpret it. Every programming language provides a set of data types. See c++ language specification on canvas for the list of data types. A variable of data type char, short, int, long, or long long stores an integer. A variable of data type float, double, or long double stores a real number. See data types sample application on canvas. Each integer data type has a capacity: a minimum and maximum possible value. While an application is running, if the minimum possible value is exceeded (an underflow) or the maximum possible value is exceeded (an overflow), the variable value wraps around. 32,768 (min) i = i + 1 s = s 1.