Previous Next
0 / 15
Module DEMO-33-65DEMO-OOP-33

Age Classifier

DEMO-OOP-33 โ€ข Object Oriented Programming

Browser-only practice

Problem Statement

Write a C program that reads a person's age and determines whether they are eligible to vote. In most countries, the voting age is 18 or older. Your program should read an integer representing a person's age and print whether they can vote or not.

If the person is 18 years or older, print "Eligible to vote". Otherwise, print "Not eligible to vote".

Constraints

The age will be a non-negative integer Age will be less than 150

Input Format

The input consists of a single integer representing the person's age.

Output Format

Print exactly one of the following messages:

  • "Eligible to vote" (without quotes) if the person is 18 or older
  • "Not eligible to vote" (without quotes) if the person is younger than 18

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
25
Eligible to vote
Age 25 is greater than or equal to 18, so the person is eligible to vote.
Sample #2
Public sample
17
Not eligible to vote
Age 17 is less than 18, so the person is not eligible to vote.

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings