Home   |   About   |   Terms   |   Contact    
Read & Learn
 

Use a constant directly into C++ program, without declaring it

C++

☯ All C++ Articles     ☯ All Articles


A new product.






Popular Google Pages:




This article is regarding Use a Constant directly into C++ program, without declaring it?
Last updated on: .



◕ What will happen if we use a Constant directly into the C++ program, without declaring it?

- When we use a Variable in C++ program, then the program declarations tell the C++ compiler about that Type of the Variable.

But we can use a Constant directly into the C++ program, without declaring it.

The example is given bellow:

#include <iostream>
using namespace std;
int main(){
cout << "India: " << 1947 << endl;
return 0;
}

The output is:
India: 1974

- In the above example we use a constant directly without declaring it.



◕ How C++ will decide what type of constant it is?

- C++ stores integer constants as int Type unless we declare it as Long or Unsigned.



Related article:
How to display a value in Hexadecimal form in C++?
How to display a value in Octal form in C++?
How C++ identify the base of a number?



Popular Google Pages:



Top of the page

Amazon & Flipkart Special Products

   


Top of the page