C programming Datatype constants variables delimiters

C Programming Datatype

Since C is a small language still it supports some valuable and important datatype. Their storage is entirely different in memory. There are only four fundamental data types in C Language, which are categorized as int, char, float, and double. In C Programming Language the int, char, float, and double are used to store an integer, single character, single-precision floating-point number, double-precision floating-point number respectively. With the help of these type qualifiers, it is very easy to get some more types.

Type Qualifiers

Since C supports only four datatypes still we can use a couple of type qualifiers with these basic datatypes to get some more type of data. There exist two types of type qualifiers listed below.

  • Size type qualifiers: short, long.
  • Sign type qualifiers: signed, unsigned.

When the type qualifier unsigned is used the number is always positive. When a signed type qualifier is used number may be both positive or negative. In case the sign qualifier is not mentioned, then by default signed qualifier is assumed. The range of values for signed data types is less than the unsigned type qualifier. The reason for such difference is because, in signed type, the leftmost bit is always used to represent the sign of the data, while in unsigned type this bit is also used to represent the value.


A constant is a value that can not be changed during the execution of the C program. C mainly supports three types of constants.

  • Numeric Constants.
  • Character Constants.
  • String Constants.

Numeric Constants

It consists of only numeric digits. The Numeric Constants may or may not have the decimal point (.). In C Language there are some rules for defining the numeric constants. The numeric constants must have at least one digit. No space or comma is allowed within the numeric constants. Numeric constants can be both positive or negative by default the sign of the numeric constants is always positive. C supports only two types of numeric constants. An integer constant, and the floating-point constants.

Integer constant

The whole numbers (counting numbers without decimal numbers including zero) are referred to as the integer constant. C supports the following three types of an integer constant.

  • Decimal Integer Constant: First ten whole numbers (0, 1, 2, 3, 4, 5, 6, 7, 8, 9). The base of these numbers is 10.
  • Octal Integer Constant: First eight whole numbers (0, 1, 2, 3, 4, 5, 6, 7). The base of these numbers is 8.
  • Hexa Decimal Integer Constant: First ten whole numbers (0, 1, 2, 3, 4, 5, 6, 7, 8, 9), and the first 6 both capital and small letters of the English alphabet (A, B, C, D, E, F, a, b, c, d, e, f). The base of these numbers is 16.
  1. Note: In Octal Integer Constant the first digit must always be zero (0). Example – 05, 043, 0745, etc.
  2. Note: In hexadecimal integer constants, first two characters must be 0x or 0X. Example – 0x23, 0X654, 0x74545, etc.

By default, an integer constant is treated as the Datatype int. If the value of integer constant exceeds the range defined for the Datatype int, the type is taken to be unsigned int or long int. We can also explicitly mention the type of the constant by suffixing it with the letters l or L( for long), letters u or U (for unsigned), or with the help of the two letters words ul or UL (for unsigned long).

1988 – Integer constant of type int.
19882018UL or 19882018ul – Integer constant of type unsigned long int.
8765U or 8765u – Integer constant of type unsigned int.

Floating-point Constants

These are another kind of numeric constants and they have the decimal points. Valid floating-point constants can be given as: 5.25, 0.0076, 200.00, 143, etc. If the floating-point constants are very large or very small then they can be represented using the scientific notation. In other words, we can say that the very small or very large floating-point constants can be written in the form of mantissa and exponent.

1200000000 = 1.2*10(9) = 1.2e9.
0.00000089 = 8.9*10(-7) = 8.9e(-7).
-430000000 = -4.3*10(8) = -4.3E(8).

By default, every floating-point constant is treated as double. Still, we can define the type of constants by suffixing it with a for F for floating-point, and l or L for long double.

Character Constants

It is a single letter or character and it always written within single quotes. Each character constant has a unique integer value that is associated with it. Integral value is in fact the numeric value of the character as per the machine code. If a machine is using ASCII code, then the character ‘A’ will be represented by a numeric value 65, while ‘a’ will be represented by a numeric value 97, and the digit ‘9’ will be represented by a numeric value 57. some valid character constants can be given as: ‘5’, ‘ ‘, ‘s’, ‘A’, ‘@’, etc.

String Constants

A string constant can have 0, 1, or more than 1 characters or letters. A string is always written within the double-quotes. This is the responsibility of a compiler that is always automatically placed \0 at the end of a string. Example: “etutororg”, “2016”, ” “, etc.

User-Defined Constants

While writing a program it may be possible we have to use the same value several times, to do so we give a specific name to that value. Whenever we have to use that value we just use the name that we have given to that value. These kinds of constants are called user-defined constants or the symbolic constants. Since a symbol is assigned to a specific constant hence these user-defined constants are called the symbolic constants. For example: If we have to use a value say 2.5 multiple times in a program so we can give it a name and instead of writing 2.5 multiple times we just have to write the name that we have given to the decimal value 2.5.

Symbolic Constants (c language datatype) can be used in place of a numeric constant, character constant or, a string constant if we are doing so then the symbolic constant has to be defined at the beginning of the program. The syntax for the symbolic constants is defined as #define Name Value.
Here #define is a preprocessor directive, “Name” is the symbolic name that is given to the constant, and it is always written in the uppercase letters. The “Value” can be defined by any numeric, character, or string constant.

#define FIF 50
#define TWOROOT 1.41
#define CH ‘A’
#define NAME “Shri”


It is a placeholder or a name that is widely used to store some value(e). A variable can take different values but only one value at a time. During the execution of the program, these values can be changed. Each variable is defined under a datatype which in turn decides the type of value the variable can take. there are some predefined rules which are helpful for giving names or deciding name for a variable.

Variables Decleration

A variable must be declared before it is used in the program. The declaration of a variable involves two important parameters first is the name of the variable and second the datatype of the variable. The data type of the variables specifies that the type and the range of values that a variable can hold or Store. The data type for the variable can be int, float, char, double, or anything else under the C Datatype.

Syntax: datatype variablename
int i;
float f;
char ch;
In this example ‘i’ is an integer type, while ‘f’ and ‘ch’ are of float and character type variables respectively.

Note: While in C programming language we have the flexibility to declare more than one variable in a single declaration.

Syntax: datatype variablename1, variablename2, variablename3;
int a, b, d, var;
Here a, b, d, and var are of integer type variables.

Variables Initialisation

When a variable is declared it usually contains an undefined value this undefined value in programming is known as the garbage value. In fact, If you want to assign some initial value to the variable that you have already declared, the initial value can be assigned to that variable during the declaration of that variable. This process of initializing the value of a variable during the declaration is called the initialization of the variable.

Syntax: datatype variablename = value that you want to assign.
int i = 50;
float f = 23.78;
char ch = ‘s’;

Leave a Comment

Your email address will not be published. Required fields are marked *