Tech Study

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.

func findandtotaltwenty(num1: Int, num2: Int) -> Bool {
    if num1 + num2 == 30 || num1 == 30 || num2 == 30
 
    {
        return true
    }
    else
    {
        return false
    }
}
print(findandtotaltwenty(num1: 10, num2: 30))
print(findandtotaltwenty(num1: 15, num2: 15))
print(findandtotaltwenty(num1: 39, num2: 15))

Result

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

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

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

Function Pointer in C++

Introduction : Function Pointer in C++ Pointers: In function pointer in c++ are the variables that consist of addresses of …

Read more