fork download
  1. #include <stdio.h>
  2.  
  3. int validateIrishLicense(int year, int halfYear, char County, int Sequence1);
  4.  
  5. int main(void) {
  6. int valid=validateIrishLicense(13,1,'D',21);
  7. printf("The license is valid or not (1=valid, 0=no): %i\n", valid);
  8. return 0;
  9. }
  10.  
  11. int validateIrishLicense(int year, int halfYear, char County, int Sequence1){
  12.  
  13. int check=0;
  14.  
  15. if (year>=13 & year<=24){
  16. check=+1;
  17. }
  18.  
  19. if (halfYear==1 | halfYear==2){
  20. check+=1;
  21. }
  22.  
  23.  
  24. char valid_county[]= {'C','c','D','d','G','g','L','l','T','t','W','w'};
  25. const VAL_COUNTIES=12;
  26.  
  27. for (int i=0; i < VAL_COUNTIES; i++) {
  28. if (County==valid_county[i]){
  29. check=+1;
  30. }
  31. }
  32.  
  33. printf("The license is valid or not (1=valid, 0=no): %i\n", check);
  34. return check;
  35. // if (check==3){
  36. // return 1;
  37. // }
  38. // else{
  39. // return 0;
  40. // }
  41. }
  42.  
  43.  
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
The license is valid or not (1=valid, 0=no): 1
The license is valid or not (1=valid, 0=no): 1