Define Constants used in C Programming with Example | Allinonetuts

Define Constants used in C Programming with Example

Constant :

A constant is a data value or quantity, which is not changed. The constant is classified as two types.

constants in c programming | Allinonetuts
The primary constants are the basic constants to be used in a C program as the character constants, integer constant and real constant.

1.    Integer Constants: Integer constants refer to the numeric data value which can be used for calculation. It consists of the digit without a decimal point. The integer may be either positive or negative.

       For Example  0, 2, 123, 278, 999, 07, 01

2.    Real Constants: These are called as floating point constants. It is a base 10 number in decimal point form and exponent form.

       For Example : 30.00, 0.2, -123.678,0.3E6m

3.   Character Constants : The character constants refer to the alphanumeric characters. A character may be any single alphabet, any single digit, any special symbol or a quote (’). For Example : ‘A’, ‘7’,    ‘+’

Secondary Constants :

The secondary constants are made up from the primary constants. These are array, pointer, structure, union etc.

1.    Array : Array is a collection of similar data type. The array is defined by subscript []. It may be one-dimensional, two-dimensional and multidimensional array.

For Example int a [3],
array constant | Allinonetuts

2.    Structure: Structure is a collection of multiple data type. It facilitates the methods tor storing data in the form of records.

For Example:

struct student
char name [20];
int roll no;
char city [15];

3.    Pointer: The pointer is a variable that can hold the address of any memory variable. The pointer is useful for working with ‘function with arguments’. It is called pointer because it always points towards another variable.

stored in pointer variable | Allinonetuts
4.    Union: Union is the user defined data type same as structure, but the difference is that all member variable use the same memory locations for data Storage. So, the union can handle only one data at a time.

For Example :

union book
int bcode;
float price;
char bname [20];
Hello Viewers,
welcome to the Allinonetuts a Technical tutorial and Programming Blog Maintained by Vikas Kardam, a Web Developer and Blogger From Delhi, India.
Define Constants used in C Programming with Example was last modified: July 1st, 2017 by Vikas Kardam
Submit your review

Create your own review

Average rating:  
 1 reviews
by Vikas Kardam on All In One Tuts
C Programming Review

Nice Article

Leave a Reply

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