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 const variable in C++

Run it Now
#include<iostream>
using namespace std;

int main() {

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

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

    return 0;
}

Output:

Enter a integer value :10
Both are Equal