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

Python Examples

Introduction: Python Examples are the basic programming concepts of python like python syntax,python data types,,python operators,python if else,python comments etc.. …

Read more

C String Functions

C String Functions perform certain operations, It provides many useful string functions which can come into action. The <string.h> header …

Read more