C++ Program to check Age of a user is eligible for voting or not


In this Program, You will learn How to check Age of a user is eligible for voting or not in C++.


Age of a user is eligible for voting

if(age >= 18) { }


Example: How to check Age of a user is eligible for voting or not in C++

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

int main() {

    int age;
    cout << "Enter Age of a User :";
    cin>>age;

    if (age >= 18) {
        cout << "\nYou are eligible for voting";
    } else {
        cout << "\nYou are not eligible for voting";
    }

    return 0;
}

Output:

Enter Age of a User :
You are eligible for voting