#include <stdio.h>
/* Prototype so main() can call it */
int irishLicensePlateValidator(int yy, int halfYear, char county, int serial);
// **************************************************
// Function: irishLicensePlateValidator
//
// Purpose:
// Validates Irish license plate components for years 2013–2024
// using a TWO-DIGIT year code.
//
// Rules:
// 1) Year (yy): must be between 13 and 24.
// 2) Half-year: must be 1 (Jan–Jun) or 2 (Jul–Dec).
// 3) County: must be one of C, D, G, L, T, W (upper or lower case).
// 4) Serial: integer from 1 to 999999 (1–6 digits).
//
// Returns:
// 1 if all values are valid,
// 0 otherwise.
// **************************************************
int irishLicensePlateValidator(int yy, int halfYear, char county, int serial)
{
/* Check two-digit year: must be 13..24 */
if (yy < 13 || yy > 24) {
return 0;
}
/* Check half-year range */
if (!(halfYear == 1 || halfYear == 2)) {
return 0;
}
/* Convert county to uppercase manually */
if (county >= 'a' && county <= 'z') {
county = (char)(county - ('a' - 'A'));
}
/* Check allowed counties */
if (!(county == 'C' || county == 'D' || county == 'G' ||
county == 'L' || county == 'T' || county == 'W')) {
return 0;
}
/* Check serial number range */
if (serial < 1 || serial > 999999) {
return 0;
}
/* Everything is valid */
return 1;
}
// **************************************************
// Function: main
//
// Purpose:
// Read plate components from the user and test the
// irishLicensePlateValidator function.
// **************************************************
int main(void)
{
int yy; /* two-digit year: 13..24 */
int halfYear; /* 1 or 2 */
char county; /* C/D/G/L/T/W (upper or lower) */
int serial; /* 1..999999 */
/* Read two-digit year */
printf("Enter two-digit year (13..24): "); if (scanf("%d", &yy
) != 1) { printf("INVALID (bad input)\n"); return 1;
}
/* Read half-year */
printf("Enter half-year (1=Jan-Jun, 2=Jul-Dec): "); if (scanf("%d", &halfYear
) != 1) { printf("INVALID (bad input)\n"); return 1;
}
/* Read county letter; skip leading whitespace */
printf("Enter county (C/D/G/L/T/W): "); if (scanf(" %c", &county
) != 1) { printf("INVALID (bad input)\n"); return 1;
}
/* Read serial number */
printf("Enter serial (1..999999): "); if (scanf("%d", &serial
) != 1) { printf("INVALID (bad input)\n"); return 1;
}
/* Validate and report */
if (irishLicensePlateValidator(yy, halfYear, county, serial)) {
} else {
}
return 0;
}