Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

c

What is integer constant in C?

Kainat Asif

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Integer constant in C is a data type that is represented by const int. const int is capable of storing an integer in decimal, octal, and hexadecimal bases. The value to const int is assigned only when it is declared and cannot be changed afterward.

Declaration

The declaration of const int is shown below:

Examples

Consider the table below, which shows examples of the declaration of const int in decimal, hexadecimal, and octal bases.

Data type

Value range (in decimal)

Decimal

Hexadecimal

Octal

int

-2147483648 to 2147483647

const int num = -5;

const int num = 0x12345678;

const int num = 023;

unsigned

0 to 4294967295

const unsigned int num = 5;

const unsigned int num = 0x1AB5;

const unsigned int num = 023146;

long

-9223372036854775807 to 9223372036854775807

const long int num = 700000000;

const long int num = 0x1AB5114455667788;

const long int num = 012345671234567;

unsigned long

0 to 1844674407370955169

const unsigned long int num = 500000000;

const unsigned long int num = 0x1AB51144D56E7F8;

const unsigned long int num = 012345671234567;

RELATED TAGS

c

CONTRIBUTOR

Kainat Asif
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring