Skip to content
Home » Check Candidate is Eligible for Voting or Not in C

Check Candidate is Eligible for Voting or Not in C

Learn about Check Candidate is Eligible for Voting or Not in C in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

Check Candidate is Eligible for Voting or Not in C

The below C program takes the age as the user input. Then the given age is compared with the age eligible for voting using the if-else statement and the final result is displayed.

Program:

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

   printf("Enter the age of the candidate: ");
   scanf("%f",&age);

   if(age>=18)
   {
     printf("The candidate is eligible for voting.");
   }
   else
   {
     printf("The candidate is not eligible for voting.");
   }

   return 0;
 }

Outputs:

Enter the age of the candidate: 18
The candidate is eligible for voting.

Enter the age of the candidate: 17
The candidate is not eligible for voting.

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Codes :
Finding Largest in Three Number in C
Finding Largest in Two Number in C