
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
What are C++ Integer Constants?
Integer constants are constant data elements that have no fractional parts or exponents. They always begin with a digit. You can specify integer constants in decimal, octal, or hexadecimal form. They can specify signed or unsigned types and long or short types.
In C++ you can use the following code to create an integer constant −
#include<iostream> using namespace std; int main() { const int x = 15; // 15 is decimal integer constant while x is a constant int. int y = 015; // 15 is octal integer constant while y is an int. return 0; }
You can find the complete grammar to specify integer constants on https://msdn.microsoft.com/en-us/library/00a1awxf.aspx.
- Related Articles
- What are constants in C++?
- What are C++ Character Constants?
- How to define integer constants in JavaScript?
- What are C++ Floating-Point Constants?
- What are Enumerated Constants in C++?
- What are different types of constants in C++?
- What are Backslash character constants in C language?
- What are different types of constants in C language?
- Are there constants in JavaScript?
- What are the constants with an example in C language?
- What are constants in Kotlin and how to create them?
- What are integer literals in C#?
- What are various inbuilt methods used to access constants database in scipy.constants() module?
- Difference between C++ string constants and character constants
- PHP Constants

Advertisements