fork(1) download
  1. #include <stdio.h>
  2.  
  3.  
  4. /*
  5.  * Function: validateIrishLicense
  6.  * Description: Validates an Irish license plate
  7.  * for years 2013 through 2024.
  8.  *
  9.  * Parameters:
  10.  * year - Two-digit year (13-24)
  11.  * halfYear - Registration period (1 or 2)
  12.  * county - County registration code
  13.  * sequence - Registration sequence number
  14.  *
  15.  * Returns: 1 if valid, 0 if invalid
  16.  */
  17.  
  18. // Function Prototype
  19. int validateIrishLicense(int year, int halfYear,
  20. char county, int sequence);
  21.  
  22. int main()
  23. {
  24. int retVal;
  25.  
  26. // Test 1: Valid license plate
  27. retVal = validateIrishLicense(13, 1, 'D', 21);
  28. printf("Test 1: %d\n", retVal);
  29.  
  30. // Test 2: Invalid half year and county
  31. retVal = validateIrishLicense(13, 3, 'K', 1);
  32. printf("Test 2: %d\n", retVal);
  33.  
  34. // Test 3: Invalid sequence number
  35. retVal = validateIrishLicense(24, 1, 'C', 1245891);
  36. printf("Test 3: %d\n", retVal);
  37.  
  38. // Test 4: Valid lowercase county
  39. retVal = validateIrishLicense(20, 2, 'g', 456);
  40. printf("Test 4: %d\n", retVal);
  41.  
  42. return 0;
  43. }
  44.  
  45. // Function Definition
  46. int validateIrishLicense(int year, int halfYear,
  47. char county, int sequence)
  48. {
  49. // Validate year
  50. if (year < 13 || year > 24)
  51. {
  52. return 0;
  53. }
  54.  
  55. // Validate half year
  56. if (halfYear != 1 && halfYear != 2)
  57. {
  58. return 0;
  59. }
  60.  
  61. // Validate county
  62. if (county != 'C' && county != 'c' &&
  63. county != 'D' && county != 'd' &&
  64. county != 'G' && county != 'g' &&
  65. county != 'L' && county != 'l' &&
  66. county != 'T' && county != 't' &&
  67. county != 'W' && county != 'w')
  68. {
  69. return 0;
  70. }
  71.  
  72. // Validate sequence number
  73. if (sequence < 1 || sequence > 999999)
  74. {
  75. return 0;
  76. }
  77.  
  78. // All conditions passed
  79. return 1;
  80. }
  81.  
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
Test 1: 1
Test 2: 0
Test 3: 0
Test 4: 1