Tech Study

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

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

Java Final keyword

Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …

Read more

C++ Memory Management: new and delete

C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …

Read more