C program to check person is eligible for voting or not : To decide person eligible for voting or not
In this tutorial, we are going to see one simple program that is to check whether the person is eligible for voting or not.
For checking the eligibility for voting we have to write simple condition.
As we know, as per government the persons whose age is greater than 18 are eligible to give the vote and below age 18 are not allowed to vote.
So, using simple condition statement we check this condition and decide who is eligible and who is not eligible.
We can implement this program in two ways.
1. By taking age input from the user.
2. By taking a date of birth input from the user.
Using first method logic:-
- First, we take the input the age of the person to check eligibility for voting.
- We write the condition that is input > 18 then, if true we print person is eligible for voting
- 3 else person is not eligible.
Using second method logic:-
- Take input date of birth from the user.
- Calculate current age by date of birth of user.
- Now compare the age of person, age > 18
- If true, then a print person is eligible for voting.
- Else person is not eligible for voting.
C program to check person is eligible for voting or not
12345678910111213141516171819202122232425262728293031323334353637 | #include<stdio.h> int main() { int age ; //take input age from user printf(“Enter the age of the person: “); scanf(“%d”,&age); //check voting eligibility if (age>=18) { printf(“person is eligible for voting”); } else { printf(“person is not eligibal for voting\n”); } return 0; } |
Output

Explanation :
1. Declare variables.
age => to store age
2. Take age input.
scanf(“%d”,&age);
=> age = 25
3. Check condition for vote eligibility
if (age>=18) => 25 >= 18 condition true if block executed.
printf(“person is eligible for voting”);
Recommended posts
Numeric Pyramid Program in C With Explanation
Alphabet Pyramid Programs in C
How to Implement A Priority Queue in c
Palindrome using string function
Fibonacci Series
Factorial of Given Number