Constants and variables allow programs to become more complex. Constants are static values used during program execution and come in two types: string constants enclosed in double quotes and numeric constants that can be positive or negative integers, fixed-point, floating-point, hexadecimal, or octal values. The chapter introduces different types of constants and how they can be declared and used to develop more advanced programs.
Constants and variables allow programs to become more complex. Constants are static values used during program execution and come in two types: string constants enclosed in double quotes and numeric constants that can be positive or negative integers, fixed-point, floating-point, hexadecimal, or octal values. The chapter introduces different types of constants and how they can be declared and used to develop more advanced programs.
Constants and variables allow programs to become more complex. Constants are static values used during program execution and come in two types: string constants enclosed in double quotes and numeric constants that can be positive or negative integers, fixed-point, floating-point, hexadecimal, or octal values. The chapter introduces different types of constants and how they can be declared and used to develop more advanced programs.
After you have learned the fundamentals of programming in GW- BASIC, you will find that you will want to write more complex programs. The information in this chapter will help you learn more about the use of constants, variables, expressions, and operators in GW-BASIC, and how they can be used to develop more sophisticated programs. 6.1 Constants Constants are static values the GW-BASIC Interpreter uses during execution of your program. There are two types of constants: string and numeric. A string constant is a sequence of 0 to 255 alphanumeric characters enclosed in double quotation marks. The following are sample string constants: HELLO $25,000.00 Number of Employees Numeric constants can be positive or negative. When entering a numeric constant in GW-BASIC, you should not type the commas. For instance, if the number 10,000 were to be entered as a constant, it would be typed as 10000. There are five types of numeric constants: integer, fixedpoint, floating-point, hexadecimal, and octal. Constant Description Integer Whole numbers between -32768 and +32767. They do not contain decimal points. Fixed-Point Positive or negative real numbers that contain decimal points. Floating-Point Constants Positive or negative numbers represented in exponential form (similar to scientific notation). A floating-point constant consists of an optionally-signed integer or fixed-point number (the mantissa), followed by the letter E and an optionally-signed integer (the exponent).