Write a Swift program to test whether the last digit of the two given integer values are same or not


Introduction

I have used Swift for windows 1.9 for debugging purpose. But you can use any Swift programming language compiler as per your availability.


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

  1. func same_last_Digit(_ a: Int, _ b: Int) -> Bool {
  2. guard a < 0, b < 0
  3. else
  4. {
  5. if a % 10 == b % 10
  6. {
  7. return true
  8. }
  9. else
  10. {
  11. return false
  12. }
  13. }
  14. return false
  15.  
  16. }
  17. print(same_last_Digit(18, 22))
  18. print(same_last_Digit(5, 15))
  19. print(same_last_Digit(25, 5))

Result

swift programming languages techstudy.org

     





Related Topics





Popular Posts