Tech Study

Write a Swift program to check if a given array of integers contains 4 twice, or 8 twice

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 checknumbers(_ a: [Int]) -> Bool {
    if a == [4, 4] || a == [8, 8]
    {
        return true
    } else {
        return false
    }
}
print(checknumbers([1, 2]))
print(checknumbers([4, 4]))
print(checknumbers([8, 8]))

Result

Write a Swift program to check if a given array of integers contains 4 twice, or 8 twice
Write a Swift program to check if a given array of integers contains 4 twice, or 8 twice

TaggedWrite a Swift program to check if a given array of integers contains 4 twice

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