Write a Swift program to rotate the elements of an array of integers to left direction

Write a Swift program to compute the sum of the two integers

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.

func sumoftwonumbers(num1: Int, num2: Int) -> Int {
    if num1 == num2 
     {
        return (num1 + num2) * 3
     }
     else 
     {
        return num1 + num2
     }
 }
 
print(sumoftwonumbers(num1: 15, num2: 20))   
print(sumoftwonumbers(num1: 30, num2: 20)) 
print(sumoftwonumbers(num1: 40, num2: 50))

Result

Write a Swift program to compute the sum of the two integers
Write a Swift program to compute the sum of the two integers

Add a Comment

Your email address will not be published. Required fields are marked *