#include<stdio.h>
#include<conio.h>
main()
{
int age;
printf("\n Enter age in the years :");
scanf("%d",&age);
if (age>17)
printf("Eligible for voting");
getch();
}
The program checks whether the candidate is eligible to vote or not. It does this by taking the input of the candidate’s age in years using the scanf()
function and stores it in an integer variable age
. Then the if
statement is used to check whether the value stored in age
is greater than 17. If it is true, then it displays a message “Eligible for voting” using the printf()
function.
If the condition in the if
statement is false, i.e. the value stored in age
is less than or equal to 17, then the printf()
statement is not executed.
Finally, the program waits for the user to press any key before terminating using the getch()
function.
Thanks
Write a program to check whether the candidate age is greater than 17 or not,if yes display message Eligible for voting.