Types of C constant:
Integer Constants |
Real/float Constants |
It must not have a decimal point. | t must have a decimal point |
The allowable range for integer constants is -32768 to 32767. | Range of real constants expressed in exponential form is -3.4e38 to 3.4e38 |
The real constants could be written in one form. | The real constants could be written in two forms—Fractional form and Exponential form. |
Characters are simple alphabets such as a, b, c, d...., but with one exception. Any single-digit integer, such as 0, 1, 2, 3, 4,..., and special characters, such as $,%, +, -,*,..., etc., are similarly treated as characters in computer programming, and you can assign them to a character type variable by simply enclosing them in single quotes.
For example, we declare a character type variable ch and assign it the value 'a'.
char ch = 'a';
Strings are similar to sentences. They refer to a sequence of characters represented as a single data type. They're made up of a list of characters, which is actually an "array of characters." When passing information from the program to the user, strings come in quite handy.
Let’s see the following example to understand how to declare a string in C
/* String */
string str = "Ninjas";
HYPER ERA PVT.LTD | TERMS & CONDITIONS