Integer numbers are inadequate to represent quantities that vary continuously,
such as distances, heights, tempratures, prices and so on. These quantities
are represented by numbers consisting fractional parts like 17.548. Such
numbers are called real constants(or floating point).
Examples:
0.0083 , -0.75 , 435.36 , 247.0
These numbers are shown in decimal notation (or scientific notation)
For example the value 215.65 may be written as 2.1565e2 in exponential notation.
e2 means multiply by 10^2. The genreal form is:
mantissa e exponent |
---|
A singlr character constant (or simple character constant) contains a single
character enclosed within a pair of single quote marks.
Examples:
'5' , 'X' , ';'
Note in the above example character constant '5' is not equal to as number 5.
Character constants have a integer values known as ASCII values.
For example:
printf("%d" , 'a');
would print the number 97, the ASCII values of the letter a.
A string constant is a sequence of characters enclosed in doubble quotes
THe characters may be letters, numbers, special numbers and blank spaces.
Examples:
"HEllo" , "1987" , "Well Done" , etc
Remember that a character constant is not equivalent to string constant.
Character strings are often used in programs to build meaningful programs.
Constants | Meaning |
---|---|
\a | audible alert (bell) |
\b | back space |
\f | form feed |
\n | new line |
\r | carriage return |
\t | horizontal tab |
\v | vertical tab |
\ | single quote |
\" | double quote |
\? | question mark |
\\ | backslash |
\0 | null |
A variable is a data name that may be used to store a data value. Unlike constants
that remain unchanged during execution of a program.
A variable name can be chosen by the programmer in a meaningful way so as reflects
its functions or nature in the program.
As mentioned earlier, Variables names may consists of letters, digits, and the underscore(_)
character.
Some conditions for the variable naming in C are:
Integers are whole numbers with range of values suppourted by a particular
machine.
IN order to provide control over the range of numbers and storage space, C
has three classes of integers storage, namely short int, int and long int,
in both signed and unsigned forms.
Unlike signed integers, unsigned integers use all the bits for the magnitude
of the number and are always positive.
A single character can be defined as a character(char) type data.
CHaracters are usally stored in 8 bits of internal storage. The qualifier signed
or unsigned may be explicitly applied to char. While unsigned chars have values
between 0 and 255, signed chars have values from -128 to 127.