In this, we are going to write a simple program to validate if a candidate is eligible to vote or not, with the help of a C++ program.
This program is kept simple so we have kept only one criterion for an eligible voter that is AGE. If candidate's age is 18 or more then he/she is eligible to vote otherwise not
The code given below can be used for TURBO C++ Compiler:-
// to find voter eligiblity using if statement
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a;
cout<<"Enter the age of candidae to check his/her eligiblity to vote...\n";
cin>>a;
if(a >= 18) {
cout<<"You are ELIGIBLE to vote !";
}
else {
cout<<"You are NOT ELIGIBLE to vote !";
}
getch();
}
The code given below can be used for g++/gcc Compiler:-
// to find voter eligiblity using if statement
#include <iostream>
using namespace std;
int main()
{
int a;
cout<<"Enter the age of candidae to check his/her eligiblity to vote...\n";
cin>>a;
if(a >= 18) {
cout<<"You are ELIGIBLE to vote !";
}
else {
cout<<"You are NOT ELIGIBLE to vote !";
}
return 0;
}
#ENJOYCODING
Â
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP