Constant
Constant means Permanent variables
Value only One Time Assign not to change other time
Constant means unchangeable and read-only variable.
Constant Sntaxy
const data_type identifier = value;
const 👉👉👉👉👉 const
data_type 👉👉👉👉👉 int
identifier 👉👉👉👉👉 x
value 👉👉👉👉👉 12
Different Between Constant and Variables
| Constant | Variables |
|---|---|
| A constant does not change its value over time. | A variable, on the other hand, changes its value dependent on the equation. |
| Constant Only one Time assigns the value not change use other time. | Variable any time value assign or any time change value. |
| Constant read-only. | Variable read and change value. |
| Syntax const data_type identifier = value; Only Assign and declare one line . | Syntax Data_type Identifier = Value; |
| Only Assign and declare one line. | Other Data_type identifier; Identifier = value; |
Program
#include<iostream>
using namespace std;
main()
{
const int my = 20;
const float me= 10;
court<<my<<endl;
court<<me<<endl;
return 0;
}
Note: Explain all the code in this video.So watch this video.
Watch Video
C++ Tutorial 8 Slide
Free Learning Point
إرسال تعليق
Virtually nothing is impossible in this world if you just put your mind to it and maintain a
positive attitude.