C++Constant|Constant and Variable Difference |Tutorial 9|Part 2| For Beginners |E3 School-2020

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

1 / 4
C++ Tutorial 9 For beginner
2 / 4
Constant
3 / 4
Constant Syntax
4 / 4
Thank You

Post a Comment

Virtually nothing is impossible in this world if you just put your mind to it and maintain a
positive attitude.

أحدث أقدم