Write a Swift program that accept 2 integer values and return true if one of them is 30 or if their sum is 30


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.  
  2. func findandtotaltwenty(num1: Int, num2: Int) -> Bool {
  3. if num1 + num2 == 30 || num1 == 30 || num2 == 30
  4.  
  5. {
  6. return true
  7. }
  8. else
  9. {
  10. return false
  11. }
  12. }
  13. print(findandtotaltwenty(num1: 10, num2: 30))
  14. print(findandtotaltwenty(num1: 15, num2: 15))
  15. print(findandtotaltwenty(num1: 39, num2: 15))

Result

swift programming languages techstudy.org

     





Related Topics





Popular Posts