Program to read the age of a candidate and determine whether he is eligible to cast his/her own vote.

Here, we have a basic program example to check if the candidate is eligible to vote or not using different languages. This program is created in c language, c++, Java, and Python.

Program to check the eligibility to vote in C language

#include <stdio.h>
void main()
{
    int age;

    printf("Enter your age: ");
    scanf("%d", &age);
    if (age >= 18)
        printf("You are eligible to vote\n");
    else
        printf("You are not eligible to vote\n");
}

Program to check the eligibility to vote in C++ language

#include<iostream>
using namespace std;
int main(){
int age;

    cout<<"Enter a your age : ";
    cin>>age;
    if (age >= 18)
       cout<<"You are eligible to vote";
    else
       cout<<"You ar not eligible to vote";
}

Program to check the eligibility to vote in Python language

age = int(input("Enter your age:  "))
if age >= 18 :
    print("You are eligible to vote\n")
else:
    print("You are not eligible to vote\n")

Program to check the eligibility to vote in Java language

import java.util.*;
class age
 {
   public static void main(String[] args)
    {
      int age;
  
      Scanner s=new Scanner(System.in);
      System.out.println("Enter your age :");
      age = s.nextInt();
     if(age >= 18){
       System.out.println("You are eligible to vote");
          }
     else {
      System.out.println("You are not eligible to vote");      
          }
}
}