- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the difference between literal and constant in C++?
A literal is a value that is expressed as itself. For example, the number 25 or the string "Hello World" are both literals.
A constant is a data type that substitutes a literal. Constants are used when a specific, unchanging value is used various times during the program. For example, if you have a constant named PI that you'll be using at various places in your program to find the area, circumference, etc of a circle, this is a constant as you'll be reusing its value. But when you'll be declaring it as −
const float PI = 3.141;
The 3.141 is a literal that you're using. It doesn't have any memory address of its own and just sits in the source code.
- Related Articles
- What is the difference between literal and constant in C#?
- What is the difference between `new Object()` and object literal notation in JavaScript?
- What is the difference between constant velocity and uniform velocity?
- What is the difference between a String object and a String literal in Java?
- What is the main difference between objects created using object literal and constructor function?
- What is different between constant and variable in C++?
- What is the difference Between C and C++?
- Why String literal is stored in String Constant Pool in Java?
- What is a string literal in C++?
- What is the difference between | and || operators in c#?
- What is the difference between JavaScript and C++?
- What is 0 (zero) - A decimal literal or An octal literal in C++
- What is the difference between "std::endl" and " " in C++?
- What is the difference between overriding and shadowing in C#?
- What is the difference between String and string in C#?

Advertisements