Advertisement

C++ Program using const variable


In this Program, You will learn How to implement const variable in C++.


const int z = 10;

Example: How to Implement a const variable in C++

#include<iostream>
using namespace std;

int main() {

    const int z = 10;
    int x;
    cout << "Enter a integer value:";
    cin>>x;

    if (z == x) {
        cout << "Both are Equal";
    } else {
        cout << "Both are Not Equal";
    }

    return 0;
}

Output:

Enter a integer value:10
Both are Equal