C++ Constant
➤Constants refer to a fixed value that the program
➤Use the const Key- Word
➤This will declare the variable as constant, which means unchangeable and read-only.
Syntax
Const int myNum = value;
➤Const key-word
➤int Data-Type
➤myNum Variable
➤Value Value
Create Int Program
#include<iostream>
using namespace std;
main()
{
int myNum=20;
court<<myNum<<endl;
return 0;
}
//int change Value anytime .
Create Const Program
#include<iostream>
using namespace std;
main()
{
const int myNum=20;
court<<myNum<<endl;
return 0;
}
//const not change value
C++ Tutorial 9 Slide
Free Learning Point
إرسال تعليق
Virtually nothing is impossible in this world if you just put your mind to it and maintain a
positive attitude.