Skip to main content

Posts

Showing posts with the label constants

Symbolic Constants in C programming

A symbolic constant is a name that substitutes for a sequence of characters. The characters may represent numeric constant, a character constant or a string constant. Thus, a symbolic constant allows a name to appear in place of a numeric constant, a character constant or a string. When a program is compiled, each occurrence of a symbolic constant is replaced by its corresponding character sequence. Symbolic constants are usually defined at the beginning of a program. The symbolic constants may then appear later in the program in place of the numeric constants, character constant, etc that the symbolic constants represent. A symbolic constant is defined by writing #define name text Where name represents a symbolic name, typically written in uppercase letters, and text represents the sequence of characters that is associated with the symbolic name. It doesn’t require semicolon. For example #define TAXRATE 0.13 #define PI 3.141593 #define TRUE 1 #define FALSE 0 #defi...

Constants and Variables

Constants in C refer to fixed values that do not change during the execution of a program. There are four basic types of constants in C. They are integer constants, floating point constants, character constants and string constants. Integer and floating point constants represent numbers. They are often referred to collectively as numeric _ type constants. The following rules apply to all numeric type constants. 1. Commas and blank spaces cannot be included within the constants. 2. The constant can be preceded by a minus (-) if desired. The minus sign is an operator that changes the sign of a positive constant though it can be thought of as a part of the constant itself. 3. The value of a constant cannot exceed specified minimum and maximum bounds. For each type of constant, these bounds will vary from one C compiler to another. Integer Constants: An integer constant is an integer-valued number. Thus it consists of a sequence of digits. Integer (number) constants can b...

C Tokens(C programming Basics)

In a passage of text, individual words and punctuation marks are called tokens. Similarly, in a C program the smallest individual units are also known as C tokens. C has six types of tokens: 1. Identifiers e.g. x area __ temperature PI 2. Keywords e.g. int float for while 3. Constants e.g. -15.5 100 4. Strings e.g. “ABC” “year” 5. Operators e.g. + - * 6. Special Symbols e.g. ( ) [ ] { }