In this tutorial we are writing a C Program to Check Eligibility for voting.
To check that a person is eligible for voting or not, we need to check whether person’s age is greater than or equal to 18. For this we are reading age in a variable a and checking the condition a>=18, if the condition is true, “person will be eligible for voting” else not.
C Program:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include <stdio.h> int main(void) { int age; printf("Enter Age: \n"); scanf("%d", &age); if(age >=18) printf("Eligible for Voting! \n"); else printf("Not Eligible for Voting! \n"); return 0; } |
Output:
1 2 3 4 5 | Enter Age: 25 Eligible for Voting! |