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

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


if(condition) {
   //statement
}
C++ Program to check the age of a user is eligible for voting or not

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

#include<iostream>
using namespace std;

int main() {

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

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

    return 0;
}

Output:

Enter age of a user:20
You are eligible for voting